Change docker location

I am using a lot of docker and since i ocasionally turn on/off instances, i would like that data to be saved to storage.

I’ve changed location of docker:

nano /etc/docker/daemon.json
{
“data-root”: “/home/ubuntu/storage1-utah/docker”
}

sudo systemctl daemon-reload
sudo systemctl restart docker

And docker hello-world example works, but other things don’t, like pulling various images:

docker pull ubuntu
docker: failed to register layer: open /var/lib/dpkg/info/gcc-12-base:amd64.list: invalid argument.

I think it is somehow related to docker not working on storage.
Any ideas?

Hi,

I couldn’t reproduce the problem you’re experiencing.

Here’s my Docker version:

$ docker --version
Docker version 24.0.6, build ed223bc

Here’s what my daemon.json looks like:

$ cat /etc/docker/daemon.json
{
    "default-runtime": "nvidia",
    "runtimes": {
        "nvidia": {
            "args": [],
            "path": "nvidia-container-runtime"
        }
    },
    "data-root": "/home/ubuntu/persistent-storage/docker"
}

Here’s the output of docker image pull ubuntu:

$ docker image pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
bccd10f490ab: Pull complete 
Digest: sha256:77906da86b60585ce12215807090eb327e7386c8fafb5402369e421f44eff17e
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest

Here’s confirmation data-root is my persistent storage:

$ sudo ls -al ~/persistent-storage/docker
total 12
drwx--x--- 12 root   root   11 Mar 26 19:04 .
drwxr-xr-x  4 ubuntu ubuntu  2 Mar 26 19:30 ..
drwx--x--x  4 root   root    7 Mar 26 19:04 buildkit
drwx--x---  2 root   root    0 Mar 26 19:24 containers
-rw-------  1 root   root   36 Mar 26 19:04 engine-id
drwx------  3 root   root    1 Mar 26 19:04 image
drwxr-x---  3 root   root    1 Mar 26 19:04 network
drwx------  4 root   root    2 Mar 26 19:04 plugins
drwx------  2 root   root    0 Mar 26 19:04 runtimes
drwx------  2 root   root    0 Mar 26 19:04 swarm
drwx------  2 root   root    0 Mar 26 19:24 tmp
drwx--x---  3 root   root    2 Mar 26 19:04 vfs
drwx-----x  2 root   root    2 Mar 26 19:04 volumes

Also, user ubuntu is in the docker group:

$ id --groups --name
ubuntu users admin docker