Coder Social home page Coder Social logo

test_docker_django's Introduction

Test Docker+Django

A very basic simple Django app with Docker

Build and push the app image

  • Create the image
$> docker build -t djangoapp .
  • Push the image
$> docker tag djangoapp adeleh/djangoapp

$> docker login 

$> docker push adeleh/djangoapp

Run the app

$> docker-compose up

N.B. Go inside a container via te cmd line

$> docker exec -it CONTAINER_ID bash

Check out http://localhost:8000/

Scale the app

$> docker swarm init

$> docker stack deploy -c docker-compose.yml djangoapp

$> docker stack ps djangoapp  # all running containers of the app

$> docker stack rm djangoapp  # stop the app 

Swarm cluster

3 nodes, 1 swarm manager and 2 workers

$> docker-machine create --driver virtualbox myvm3

$> docker-machine start myvm1

$> docker-machine ssh myvm1 "docker swarm init --advertise-addr myvm1_ip"

$> docker-machine ssh myvm2 "docker join --token TOKEN myvm1_ip:2377"
$> docker-machine ssh myvm3 "docker join --token TOKEN myvm1_ip:2377"

$> docker-machine ssh myvm1 "docker node ls"  # check there are 3 nodes

$> docker-machine scp docker-compose.yml myvm1:~  # copy the file

$> docker-machine ssh myvm1 "docker stack deploy -c docker-compose.yml djangoapp"  # deploy the app on the cluster

or 

$> docker-machine ssh myvm1 "docker login -u adeleh -p pwd docker stack deploy -c docker-compose.yml djangoapp"  # if image is private

$> docker-machine ssh myvm1 "docker stack ps djangoapp -f "desired-state=Running""  # show the distributed containers between the nodes of the cluster

Check out myvm_ip:8000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.