realpython / dockerizing-django

https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/
1.34k stars 484 forks source link

Update docker-compose.yml #20

Closed slyapustin closed 8 years ago

slyapustin commented 8 years ago

Removed redundant volumes mount, which cause project folder to be inacessible

s7726 commented 8 years ago

The volumes aren't redundant. They are intended to allow continued development. That particular yml file isn't for production.

slyapustin commented 8 years ago

Yeah, if you want to also update project on host machine and see changes in docker container, you should mount such folders as volume.

I thought there couple important things which need to be mentioned in Readme.md for windows users:

1) using docker exec, instead of docker run command 2) mounting host folders for dev purposes https://docs.docker.com/v1.8/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume

antonichoudhuri commented 8 years ago

Removing the volumes fixed my issue while running this on Windows.

I am not sure what @inoks meant by:

1) using docker exec, instead of docker run command

The guide uses docker-compose which doesn't have exec.

mjhea0 commented 8 years ago

@s7726 and @inoks what are you using for your volumes? I think the web process needs to be updated in the .yml file to:

web:
  restart: always
  build: ./web
  expose:
    - "8000"
  links:
    - postgres:postgres
    - redis:redis
  volumes:
    - /usr/src/app
    - /usr/src/app/static
  env_file: .env
  command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000

So the volumes should be:

  volumes:
    - /usr/src/app
    - /usr/src/app/static

Thoughts?

s7726 commented 8 years ago

It depends on your goal. The way the docker_compose.yml is written is for testing. Look at the production.yml for something for production. No need to list the volumes at all in the production one. The files are copied over in the Docker file.

mjhea0 commented 8 years ago

@inoks:

Can you update the PR to:

  volumes:
    - /usr/src/app
    - /usr/src/app/static