Skip to content

Instantly share code, notes, and snippets.

@alecthegeek
Last active August 28, 2018 12:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alecthegeek/8122a70edad133279fa33a7eddfb1705 to your computer and use it in GitHub Desktop.
Save alecthegeek/8122a70edad133279fa33a7eddfb1705 to your computer and use it in GitHub Desktop.
An example of using --volumes-from option in Docker
#!/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