Skip to content

gogobook/dockerizing-django

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Development With Docker Compose and Machine

Featuring:

  • Docker v1.17.x
  • Docker Compose v1.12.0
  • Python 3.6 (With an virtul environment)

Blog post -> https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/

OS X Instructions

  1. Start new machine - docker-machine create -d virtualbox dev;
  2. Build images - docker-compose build
  3. Start services - docker-compose up -d
  4. Create migrations - docker-compose run web /usr/local/bin/python manage.py migrate todo
  5. Grab IP - docker-machine ip dev - and view in your browser

Ubuntu Instructions

  1. Start a python virtul environment, pip install docker-compose
  2. Point docker to VM (you may need to start the vm docker-machine start dev), eval $(docker-machine env dev)
  3. build images - docker-compose build
  4. Start services -docker-compose up -d
  5. Create Database in postgres -psql -h 192.168.x.x -p 5432 -U postgres create database my_db \l check List of databases.
  6. Create migrations -docker-compose run web python manage.py migrate

Note

requirements.txt is update. docker-compose.yml is update. production.yml is not update. If you have old pgdata volume, remember delete it, or your will get errors.

postgres_1  | FATAL:  database files are incompatible with server
postgres_1  | DETAIL:  The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.2.

docker-compose down won't delete volumes! You should do it by manual. docker-compose.yml 中的volume的路徑要用絕對路徑。 postgresql 要另建my_db

changelog

update in 2017/04/31 rm -rf static Execute export $(cat .env) then python manage.py collectstatic Django static dircetly serve by nginx, so I chaged nginx Dockerfile. In docker-compose, nginx add volume from web/static to /static

update in 2017/04/16. Dockerfile of nginx changed. Dockerfile of web update to python:3.6

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 54.8%
  • CSS 36.7%
  • Python 5.5%
  • TypeScript 2.2%
  • HTML 0.8%