Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving docker root folder to a new drive / partition

Tags:

docker

lxc

I am trying to move the "/var/lib/docker" folder from one disk to another since that is taking up too much space. I keep running into some errors relating to permissions!

According to these questions:

  • How do I move a docker container's image to a persistent disk?
  • How to run docker LXC containers on another partition?

My disk is mounted on "/data" and I copied the "/var/lib/docker" folder to "/data/docker"

This is what I tried:

  • Tried out the -g flag from DOCKER_OPTS with "/data/docker"
  • Tried creating a symbolic link from the new disk drive
  • I tried doing a bind mount from /data/docker

However in all the cases, I get an error when I try to launch services inside my container about missing permissions to write to "/dev/null" (as user root).

I simply did a copy of the folder to the new disk. This copied all the permissions as well (This is an ext4 system with same filesystem level permissions as the original disk on which docker exists now).

Specs:

  • The fileystem I am using is aufs.
  • Docker version is 0.7.6
  • Ubuntu 12.04

How do I move the data properly? Do I need a upgrade first?

like image 766
mirage Avatar asked Dec 12 '22 05:12

mirage


1 Answers

I just did the following and it seems to work well:

as root:

service docker stop
mv /var/lib/docker /data/
# reboot and get root
service docker stop
rm -rf /var/lib/docker && ln -s /data/docker /var/lib/
service docker start
like image 99
Karl Forner Avatar answered Jan 21 '23 01:01

Karl Forner