简体   繁体   中英

How to change the dir root of docker image storage

I using docker to build some images. To space drive space I decide to change the default docker images and containers storage ('/var/lib/docker') to my additional drive ('/mnt')

I change the '/lib/systemd/system/docker.service', and add

'ExecStart=/usr/bin/dockerd -H fd:// -g /mnt/data'

The problem is when I indicate dir root like that it works like a charm, but if I want to go deeper, for example

'ExecStart=/usr/bin/dockerd -H fd:// -g /mnt/data/subFolder/AABB'

When I 'systemctl daemon-reload' and 'service docker restart' I got error:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Wed 2017-08-16 16:25:28 EDT; 46s ago
     Docs: https://docs.docker.com
  Process: 4543 ExecStart=/usr/bin/dockerd -H fd:// -g /mnt/data/subFolder/AABB (code=exited, status=1/FAILURE)
 Main PID: 4543 (code=exited, status=1/FAILURE)

Aug 16 16:25:28 myserver systemd[1]: Failed to start Docker Application Container Engine.
Aug 16 16:25:28 myserver systemd[1]: docker.service: Unit entered failed state.
Aug 16 16:25:28 myserver systemd[1]: docker.service: Failed with result 'exit-code'.
Aug 16 16:25:28 myserver systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Aug 16 16:25:28 myserver systemd[1]: Stopped Docker Application Container Engine.
Aug 16 16:25:28 myserver systemd[1]: docker.service: Start request repeated too quickly.
Aug 16 16:25:28 myserver systemd[1]: Failed to start Docker Application Container Engine.

I have check the ownership and right for them which are

drwxr-xr-x 3 root root 4096 Aug 16 16:23 data
&
drwxrwxrwx 4 root  root 49 Aug  8 10:23 AABB

Does anyone have idea why that happens? Any help appreciated!

A bit update, I find after I change the root (eg"/mnt/data") the right of this folder is changed as well

drwx--x--x 12 root root 4096 Aug 16 16:40 data

Although it is doable to change it back, It would be great if you can give me some clue

Here is more update, the /subFolder/ seems to be NFS share folder, that might be the reason.

So it there any way that I can use the folder as docker image and container storage?

images are sored in /var/lib/docker/overlay2

you can move this folder and than create symlink to it new location

systemctl stop docker
mv /var/lib/docker/overlay2 /raid/docker-overlay2-data
ln -s /raid/docker-overlay2-data /var/lib/docker
systemctl start docker

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM