realpython / dockerizing-django

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

data container pattern obsolete #21

Closed oppianmatt closed 8 years ago

oppianmatt commented 8 years ago

docker now no longer cleans up volumes that aren't referenced so the docker data container pattern is obsolete.

https://docs.docker.com/engine/userguide/containers/dockervolumes/

Data volumes persist even if the container itself is deleted.

So you can remove the data entry in compose and replace the postgres entry with:

postgres:
  restart: always
  image: postgres:latest
  ports:
    - "5432:5432"
  volumes:
    - pgdata:/var/lib/postgresql/data/

This uses a named volume (so you can find it easily).

Should probably give redis a volume to so it's persisted:

redis:
  restart: always
  image: redis:latest
  ports:
    - "6379:6379"
  volumes:
    - redisdata:/data
mjhea0 commented 8 years ago

Thanks! Updating the code and the blog post now!