Docker - Trying to dockerize my Django app

I've spent sometime messing around the docker engine for couple days. I guess It's time to try dockerizing my Django app.

Assuming I have already created a Ubuntu Trusty image , open a container:

  • Prerequisites:

* The container (by default: eth0 - python2.7, pip, virtualenv, mysql-client
* The host machine (by default: docker0 - mysql-server, grant permisson to the container host:

MariaDB [(none)]> use appdb;
MariaDB [appdb]> grant all privileges on appdb.* to 'myuser'@'' identified by 'mypassword';

  • Inside the container:

(mydjangoenv)root@93b3f27d3129:~# git clone https//my.git.repo/myproject
(mydjangoenv)root@93b3f27d3129:~# cd myproject
(mydjangoenv)root@93b3f27d3129:~# pip install -r requirements.txt
(mydjangoenv)root@93b3f27d3129:~# ./manage run

(remember to add the container's hostname (93b3f27d3129) to ALLOWED_HOSTS )

  • In the host machine: Open the browser, enter to use the app.
  • Final step: commit the changes of the container on the host machine to create a new image
$ sudo docker commit 93b3f27d3129 mydjangoapp

Now I have a dockerized django app.