docker build -t volume-tester .
mkdir tmpvolume
docker run -d -it --name voltest --mount type=bind,source="$(pwd)"/tmpvolume,target=/app --rm volume-tester:latest
ls tmpvolume
cat tmpvolume/*
Not in video but the container is gone at this point with the --rm
flag but data persisted.
NOTE: --mount
is preferred syntax in later version of Docker for bind mounts but the following would also work with the --volume
or -v
flags.
docker run -d -it --name voltest -v "$(pwd)"/tmpvolume:/app --rm volume-tester:latest