Two daemon Docker : 2nd daemon attempting to use 1st containers

I need to run two instances of docker on the same Ubuntu 22 (or 24) server. I know this is possible via e.g. [this URL] and [this URL] 1 2

The first dockerd is already running via the default Ubuntu install and settings.

To start the 2nd, I use the command:

sudo dockerd \
  -H unix:///var/run/docker-extra.sock \
  --pidfile=/var/run/docker-extra.pid \
  --config-file=/etc/docker/daemon-docker-extra.json \
  --iptables=true \
  --ip-masq=true \
  --bridge=none \
  --exec-root=/var/run/docker-extra

I really want to use bridge=docker1 but cannot create docker1 until the daemon is up, so I use bridge=none for now and will create the new bridge when the Daemon is up (will this work?). I also have a config file at /etc/docker/daemon-docker-prod.json

{
    "data-root": "/home/docker_extra_root_dir"
}

However, when I run the command I get continuous errors, e.g:

ERRO[2025-11-07T13:16:01.197165973Z] failed to process event container=cfbc653d38e16cc8236e4d965c7cfd47378644e1d9dc7a63a62d6d92d573ea40 error="could not find container cfbc653d38e16cc8236e4d965c7cfd47378644e1d9dc7a63a62d6d92d573ea40: No such container: cfbc653d38e16cc8236e4d965c7cfd47378644e1d9dc7a63a62d6d92d573ea40" event=exit event-info="{cfbc653d38e16cc8236e4d965c7cfd47378644e1d9dc7a63a62d6d92d573ea40 ca38900f5c5eee3f19dc2ef562865bc4fce22b3753762ed7e81209285b7d8a8834502 0 2025-11-07 13:16:01.19664609 +0000 UTC <nil>}" module=libcontainerd namespace=moby

If I look up the container IDs in the errors, I see they are actually containers that the 1st daemon is running! How does the 2nd daemon even know those exist? Why is it trying to mess with them? I thought the data-root setting in the json should ensure the two daemons don’t know about each other. Is there another setting I need to change?

I validated the json config OK, and the other daemon has json config that just says "hosts": ["fd://"] . Any advice welcome.

First of all, I have no idea how to run two docker daemons on a single host, unless both are either run in separate lxc containers or vms. It doesn’t make sense to me to run two rootfull daemons on the same host.

Anyhow, I wonder how the two docker instances are distinguished on containerd level.
After all both delegate container and starting with docker v29 the image handling to containerd.

Unless there is a way to specify a different dockerd namespace for each docker instance, I am not sure how this is supposed to work, as the state would end up in the same containerd instance. Docker uses the moby namespace in containerd. I have no idea if it’s possible to configure a different namespace per instance.

You can list existing namespaces and containers like this:

sudo ctr namespaces list
sudo ctr --namespace moby containers list

Update:
it seems you can configure the containerd-namespace it in the deamon.json:

...
  "containerd": "/run/containerd/containerd.sock",
  "containerd-namespace": "docker",
  "containerd-plugins-namespace": "docker-plugins",
...

See: https://docs.docker.com/reference/cli/dockerd/#on-linux

You could try if changing the namespaces is enough, or whether you require a second instance of containerd as well.