Docker Storages - Overview

  • Volumes
  • Bind mounts
  • Tmpfs


Docker volume (Image from
  • Volumes are preferred since the storage location is managed by docker
  • Volumes can be created explicitly or while creating the container
  • Name of the volume. Anonymous volumes also can be created, in which docker will name it uniquely.
  • Path where directory/file is mounted inside the container. e.g. In case of MSSQL its the data path where the data is stored.
  • [Optional] Comma separated options list. e.g. ro is given for read only volumes
  • source : Name of the volume. Omit this field to create anonymous volume.
  • destination : path where the file/directory is mounted in the container
  • type : The value is volumealways.

Create a volume explicitly

docker volume create <vol_name> // <vol_name> should be replaced by     name of volume

Create a volume while spinning up the container

//using -v
docker run -v <vol_name>:<destination_path> <image>
//using --mount
docker run --mount source=<vol_name>,target=<destination_path>,type=volume <image>

Inspect a volume

docker inspect <vol_name>

Remove a volume

docker volume rm <vol_name>

Bind Mounts

Bind mounts (Image from

Create a bind mount while spinning up the container

docker run --mount type=bind,source=<source_path>,target=<target_path> <image> // <source_path> should be replaced by absolute path. e.g. if the the folder is called target in current working directory, then it should be "$(pwd)"/target.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store