Running a Docker Container in Different hard Disk Partition and keeping the Docker Images on Different Hard Disk Partition

Viewed 23

My Problem is i have Ubuntu Machine , and 2 partitions root and home . I have a Docker Image of MySQLDB which of 100GB. I keep them under root -> /var/lib/docker. Docker images itself uses 100GB of my root partition.

Now If I run this particular docker image -> Container gets created and tries to use another 100 GB of Hard Disk on root partition while running the Docker Container.so 200 GB it uses from root partition.

Is there anyway i can keep the docker images on root partition, and while running them, i want the container to use the other partition in hard disk (not the same where the images are stored).

I am not sure whether this is feasible. Thanks in Advance for the help.

1 Answers

make a soft link for image folder

systemctl stop docker
mv /var/lib/docker/image /partition_2/
ln -s /partition_2/image /var/lib/docker/image
systemctl start docker
Related