Skip to content

Docker VolumesΒΆ

Docker Volumes are a storage mechanism to persist data during the starting/stopping of Docker containers, or between Docker containers.

Most information can be found using the docker volume command.

For example, docker volume create my-volume will create a Docker volume that can now be viewed using docker volume ls.

Additionally, you can use docker volume inspect my-volume to get additional information about the volume

A typical use case for Docker Volumes is if you have a local database container running, such as MongoDB. In this case, you don't want to lose all your data in the case that you have to restart your container. So, you would store the data in an external Docker Volume.

To mount a volume to a counter, you can rather specify the volume attribute in your docker-compose.yml file as such:

version: '3.7'

services:
  frb-master:
    image: chimefrb/frb-master:latest
    container_name: frb_master
    volumes:
      - .:/frb-master
    ports:
      - "8001:8001"

Or, if you're not using docker-compose, you can attach the following flag to your docker run:

-v <name>:<destination>:<options>
docker run -it -v demo-volume:/data:ro ubuntu # ro = read-only