Last active
August 28, 2018 12:42
-
-
Save alecthegeek/8122a70edad133279fa33a7eddfb1705 to your computer and use it in GitHub Desktop.
An example of using --volumes-from option in Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
docker container rm -f writer reader | |
docker volume rm testdata | |
docker container run --mount source=testdata,target=/tmp/data --name=writer -d alpine /bin/sh -c 'while echo $(( m += 1 )) >> /tmp/data/1 ; do sleep 5 ; done' | |
docker container inspect --format '{{.Mounts}'} writer | |
docker container run --volumes-from writer --name=reader -d alpine /bin/sh -c 'while true ; do sleep 600 ; done' | |
docker container inspect --format '{{.Mounts}'} reader | |
docker container exec -it reader tail -f /tmp/data/1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment