Can I share the image layer between two daemon with symbol link?

I have multiple docker daemon on the same host and each have a different data-root, but I want only one of them doing the image pull and others are only reuse the existing image layer. I have created a symbol link for all files under {data-root}/image and {data-root}/overlay2, but when I trying to launch a container with the following command:

docker -H unix:///home/sli/docker2.sock run test:61 sleep 120

I see the following error on the daemon process:

ERRO[2023-09-21T15:40:13.641483113-07:00] error unmounting /home/sli/docker1/overlay2/dd2a15ed3fc29a3cdbe14f21821515bc3afb5e25f90837cf28fdab36db586f5a/merged: invalid argument storage-driver=overlay2
DEBU[2023-09-21T15:40:13.646432384-07:00] FIXME: Got an API for which error does not match any expected type!!!: error creating overlay mount to /home/sli/docker1/overlay2/dd2a15ed3fc29a3cdbe14f21821515bc3afb5e25f90837cf28fdab36db586f5a/merged: no such file or directory error_type=“*errors.errorString” module=api
ERRO[2023-09-21T15:40:13.646458306-07:00] Handler for POST /v1.38/containers/create returned error: error creating overlay mount to /home/sli/docker1/overlay2/dd2a15ed3fc29a3cdbe14f21821515bc3afb5e25f90837cf28fdab36db586f5a/merged: no such file or directory
DEBU[2023-09-21T15:40:13.646469611-07:00] FIXME: Got an API for which error does not match any expected type!!!: error creating overlay mount to /home/sli/docker1/overlay2/dd2a15ed3fc29a3cdbe14f21821515bc3afb5e25f90837cf28fdab36db586f5a/merged: no such file or directory error_type=“*errors.errorString” module=api

I have tryed both docker image ls, docker container ls and even tryed to pull a image on that daemon, seems all works but this run command doesn’t.

A little background for the design, I got multiple disk mounted on the same host, I want the container launched by different users just consume their own disk.

Symlinking to another Docker data root is a bad idea. Each daemon has to handle its own Docker data root and you can’t use a common place for images while running containers with multiple daemons. Docker was not designed to work that way. Each user with their own daemon has to pull their images.

You could probably use OpenPolicyAgent easier to restrict what users can do and have only one docker daemon

Here is an older YouTube video about it:

But You can find more recent sources as well.

Don’t change anything in the Docker data root. Let that be handled entirely by Docker.

1 Like