Low Orbit Flux Logo 2 F

Docker How To Access Volume From Host

We’re going to show you how to:

First create a volume to test with:



docker volume create my_volume

Next, launch a container with that volume attached. Specify where that volume will be mounted within the container. The directory will be created if it doesn’t exist.



docker run -tid -v my_volume:/path/in/container ubuntu

Inspect the volume, this will show you where it is mounted on the host system:



docker inspect my_volume

Show the files within the volume from the host system:



ls /var/lib/docker/volumes/my_volume/_data

Create a test file within the volume:



touch /var/lib/docker/volumes/my_volume/_data/test.txt

Check the details for your container:



docker ps -a

Attach to the container:



docker attach laughing_solomon

List the files in the volume from within the container:



ls /path/in/container