Skip to content

Instantly share code, notes, and snippets.

@ianfoo
Created March 5, 2019 22:19
Show Gist options
  • Select an option

  • Save ianfoo/a0f36f18cba42f80aefaa1f0b386fb02 to your computer and use it in GitHub Desktop.

Select an option

Save ianfoo/a0f36f18cba42f80aefaa1f0b386fb02 to your computer and use it in GitHub Desktop.
Example of volume mounting in Docker
[ian@ianbook docker] $ cat > Dockerfile
FROM alpine:latest
CMD cat /mounted-file.txt
[ian@ianbook docker] $ docker build -t voltest .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM alpine:latest
---> caf27325b298
Step 2/2 : CMD cat /mounted-file.txt
---> Running in b0d00cf05b6f
Removing intermediate container b0d00cf05b6f
---> daf551c6dc74
Successfully built daf551c6dc74
Successfully tagged voltest:latest
[ian@ianbook docker] $ echo "This should display from within Docker" > file-to-mount.txt
[ian@ianbook docker] $ docker run --rm -v $PWD/file-to-mount.txt:/mounted-file.txt voltest
This should display from within Docker
[ian@ianbook docker] $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment