Docker Community Forums

Share and learn in the Docker community.

Can I store Docker containers on two different mount points of the same machine?


(Mpreusse) #1

I have a SSD mounted on /mnt/ssd and a HDD on /mnt/hdd.

Can I store/run some containers (the database) on the SSD and other containers (other parts of the application) on the HDD? I know how to set a new global directory for Docker. But is it also possible to split the containers up and store the volumes on different mount points?

(Joshnw) #2

Docker container storage is broken into two components

The first storage component is controlled by the docker storage driver

  • this represents the copy-on-write portion of the container used to store the underlying docker image and the write layer used by the container
  • To mount this area to more than one location is not generally done by default and would require you to use some outside-the-box solution such as docker-in-docker

The second storage component is controlled by volume plugins

  • by default this stores externally mounted data (or data not managed by the copy-on-write process) to /var/lib/docker/volumes
  • however you may use the docker local-presist volume plugin to specify specific directories, like /mnt/ssd or /mnt/hdd, outside the docker root path to store mounted data. This may be the best alternative for your situation ( )

(Mpreusse) #3

Thanks for the detailed answer.

I think the most reasonable solution is to store the database folder on the SSD and mount it in the Docker container. This does not offer the convenience and flexibility of named volumes but should be the easiest way.

The local-persist plugin looks promising though!