Different Types of Volumes

Article ID: KB000217

There are three types of volumes: host, anonymous, and named:

  • A host volume lives on the Docker host's filesystem and can be accessed from within the container. To create a host volume:

    docker run -v /path/on/host:/path/in/container ...
  • An anonymous volume is useful for when you would rather have Docker handle where the files are stored. It can be difficult, however, to refer to the same volume over time when it is an anonymous volumes. To create an anonymous volume:

    docker run -v /path/in/container ...
  • A named volume is similar to an anonymous volume. Docker manages where on disk the volume is created, but you give it a volume name. To create a named volume:

    docker volume create somevolumename
    docker run -v name:/path/in/container ...