If you need some quick commands to paste to check if your docker volume mounting is working correctly here you go!

Commands below!

Test a file mount

echo foo > /tmp/docker-test docker run --rm -it -v /tmp/docker-test:/tmp/docker-test alpine cat /tmp/docker-test
Code language: JavaScript (javascript)

You should see this output.

foo

Test a directory mount

mkdir /tmp/docker-test-dir echo bar > /tmp/docker-test-dir/test docker run --rm -it -v /tmp/docker-test-dir:/tmp/docker-test-dir alpine ls -lahr /tmp/docker-test-dir && cat /tmp/docker-test-dir/test
Code language: JavaScript (javascript)

You should see this output like this.

total 12K -rw-r--r-- 1 1000 1000 4 Jan 5 19:33 test drwxrwxrwt 1 root root 4.0K Jan 5 19:33 .. drwxr-xr-x 2 1000 1000 4.0K Jan 5 16:52 . bar
Code language: CSS (css)

Cleanup

To clean everything up you can run these commands.

rm /tmp/docker-test rm /tmp/docker-test-dir/test rmdir /tmp/docker-test-dir

And if you no longer want the image.

docker image rm alpine