Volumes

Volumes allow containers to access a dir on the host machine.

This location is called the Mountpoint.

Manage

Create

docker volume create volumeName

docker volume create # returns the name of the created volume

List

docker volume list

Inpect

docker volume inspect volumeName

Remove

docker volume rm volumeName

Prune

Removes all volumes not being used by a container

docker volume prune


Enable Access via Container

Run with volume

docker run --volume volumeName:/var/lib/my/mount/point

# for nameless volumes, docker will handle its life cycle
docker run --volume /var/lib/my/mount/point 

# mapping the mountpoint to a dir on the container
docker run --volume /var/lib/my/mount/point/on/host:/var/lib/container