Sviatoslav
Sviatoslav

Reputation: 1312

How to store named docker volume with mysql data on external disk (mac os)?

I have installed docker on my Mac on SSD. Docker.qcow2 located on Mac too. So, named volume with mysql data in 100GB is located in this Docker.qcow2 on SSD too! I want to store named volume with mysql data on the external HDD and connect it to the docker container on the Mac. For me it is ok too store all containers on SSD but some huge named volumes on external cheap disc. Is it possible and how?

Upvotes: 2

Views: 1554

Answers (1)

kstromeiraos
kstromeiraos

Reputation: 5027

Map the route to a directory in your external disc to /var/lib/mysql inside the container. This will write contents of your /var/lib/mysql directory (inside the container) to a directory in your external hard disk.

To do this, use option -v host_directory:container_directory in your docker run command.

Check this reference for further information: https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-directory-as-a-data-volume

Upvotes: 1

Related Questions