|
|
|
|
|
by StavrosK
4691 days ago
|
|
Docker sounds brilliant, but I haven't had much luck with deploying my (moderately complex) Django apps on it. For example, I want the postgres db data to live outside the container, but volumes can't currently do that with Dockerfiles: they're initialized at "docker build" and then the files are just overwritten when trying to mount an external volume. Another use case is trying to spin up a development container (where the code resides on the host), but, again, shared volumes overwrite the directory. You can ADD your code initially and then mount the volume when you run it, but it's added hassle. |
|
This is by design, "I want the postgres db data to live outside the container" is a deployment-specific decision, and should not be hardcoded into the container itself. You (or someone you distribute this container to) might not want the db data to live outside the container, or might want it to live at a specific path on his machine. That's why a Dockerfile lets you specify that /var/lib/postgres is persistent, but doesn't let you specify how to persist it.
Now, if I remember our IRC discussion correctly, in your case you're hitting a limitation of docker's implementation of volumes, which is that the container cannot specify an initial state for its volume - it can only start empty. That is a limitation that we're going to fix. But we need to make sure we fix it without breaking portability of containers.
I hope this helps.