2 ms·
Am intrigued (and, again, showing my current early-stage understanding of LXCs), can you link the same data store container to multiple application containers?
by wastedhours 12y ago
Am intrigued (and, again, showing my current early-stage understanding of LXCs), can you link the same data store container to multiple application containers? As in, have both a beta application and production application pulling data from the same core DB?
And do you simply define the container as a volume to ensure it stays persistent? That was the feeling I got from the docs, but again, might just be flagging how little I know at the minute...
- TheDong 12y agodocker run --name=my-data -v /host/data:/container/data data-container docker run --volumes-from=my-data app-beta-container docker run --volumes-from=my-data app-prod-container That would share the data store, however the real way you'd do this would be.... docker run --name=my-data -v /host/data:/container/data data-image docker run --volumes-from my-data --name my-database database-image docker run --link=my-database beta-app docker run --link=my-database prod-app Doing --link will allow those two containers to network-communicate and you should only be communicating with your database over the network anyways.
- shykes 12y agoYes, you can definitely share volumes between any number of containers, it's a common usage pattern. You don't need to make a container persistent: Docker, by design, will never remove anything unless you explicitly ask it to. If you want to separate the lifecycle of a directory within your container, so that it stays behind after you explicitly remove the container, or to share it between containers - that's when volumes are useful.