How move docker data to other dir in ubuntu/debian

Stop docker

sudo systemctl stop docker
nano /etc/docker/daemon.json 

Add data

{
  "data-root": "/new/path/to/docker-data"
}

Check docker has been stopped

ps aux | grep -i docker | grep -v grep

Copy the files to the new location

sudo rsync -axPS /var/lib/docker/ /new/path/to/docker-data

Options explanation, check out the man page for more info

-a, --archive             archive mode; equals -rlptgoD (no -H,-A,-X)
-x, --one-file-system     don't cross filesystem boundaries
-P                        show progress during transfer
-S, --sparse              handle sparse files efficiently

Start Docker back up

sudo systemctl start docker

Check Docker has started up using the new location
docker info | grep ‘Docker Root Dir’
Check everything has started up that should be running
docker ps
Leave both copies on the server for a few days to make sure no issues arise, then feel free to delete it.

sudo rm -r /var/lib/docker

Добавить комментарий

Войти с помощью: 

Ваш e-mail не будет опубликован. Обязательные поля помечены *

 

Этот сайт использует Akismet для борьбы со спамом. Узнайте как обрабатываются ваши данные комментариев.