matanox
matanox

Reputation: 13686

Can docker containers share a directory amongst them

Is it possible to share a directory between docker instances to allow the different docker instances / containers running on the same server directly share access to some data?

Upvotes: 0

Views: 158

Answers (2)

Bryan
Bryan

Reputation: 12190

Yes, this is what "Docker volumes" are. See Managing Data in Containers:

Mount a Host Directory as a Data Volume

[...] you can also mount a directory from your own host into a container.

$ sudo docker run -d -P --name web -v /src/webapp:/opt/webapp training/webapp python app.py

This will mount the local directory, /src/webapp, into the container as the /opt/webapp directory.

[...]

Creating and mounting a Data Volume Container

If you have some persistent data that you want to share between containers, or want to use from non-persistent containers, it's best to create a named Data Volume Container, and then to mount the data from it.

Upvotes: 2

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657238

You can mount the same host directory to both containers docker run -v /host/shared:/mnt/shared ... or use docker run --volumes-from=some_container to mount a volume from another container.

Upvotes: 2

Related Questions