Created
March 5, 2019 22:19
-
-
Save ianfoo/a0f36f18cba42f80aefaa1f0b386fb02 to your computer and use it in GitHub Desktop.
Example of volume mounting 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
| [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