0

I have changed the default docker folder like it is described in the topic : How do I change the default docker container location?:

  1. stopped docker
sudo systemctl stop docker && systemctl stop docker.socket
  1. modified /etc/docker/ daemon.json
{
   "data-root":/mnt/disk/docker"
}
  1. copied a data from /var/lib/docker to /mnt/disk/docker
cp -rp /var/lib/docker /mnt/disk/docker
  1. start the docker
sudo systemctl daemon-reload
sudo systemctl start docker

I can see that docker is using /mnt/disk/docker after changes but docker can't find containers and images. I restored the docker configuration but docker can't find a containers and images in the old directory.

Does anyone have a idea what is wrong? How to restore?

Meow Meow
  • 637
  • 6
  • 17
  • can you post the result of following command ? ```docker info -f '{{ .DockerRootDir}}'``` – Micheal Choudhary May 24 '23 at 11:05
  • @MichealChoudhary the result is ```/var/lib/docker``` – Meow Meow May 24 '23 at 11:08
  • docker is still using the old directory – Micheal Choudhary May 24 '23 at 11:11
  • are you sure, you did modified the daemon.json correctly and stopped docker, docker.socket and container runtime containerd before making changes in daemon.json? id not do it with following commands. ``` sudo systemctl stop docker sudo systemctl stop docker.socket sudo systemctl stop containerd ``` – Micheal Choudhary May 24 '23 at 11:12
  • @MichealChoudhary it is using the old directory because i have returned configuration. the problem is that ```docker container ls```, ```docker images``` is returning nothing. I haven't stopped containerd, to be honest. Shall I restart it? – Meow Meow May 24 '23 at 11:22

1 Answers1

0

Docker maybe using old root directory

Validate the new Docker root location by executing following command: docker info -f '{{ .DockerRootDir}}'

if the result is path of old directory, then you did something wrong. Please go through the steps to relocate the Docker root directory again and dont forget to stop docker, docker.socket and container runtime containerd :

sudo systemctl stop docker
sudo systemctl stop docker.socket
sudo systemctl stop containerd