I've just experienced this problem, i cannot start / restart docker or docker.service with systemctl command. I've just configuring the TCP socket listening in /etc/docker/daemon.json file and all works when i'm manually run the docker daemon, but every time i try to handle the service with systemctl i get the error:
Ubuntu22.04 LTS
Docker version 20.10.18, build b40c2f6
systemd 249 (249.11-0ubuntu3.4)
/etc/docker/daemon.json
{
"hosts": ["unix:///var/run/docker.sock","tcp://localhost:2375"],
"dns": ["8.8.4.4","8.8.8.8"]
}
# not works
sudo systemctl restart docker
> Job for docker.service failed because the control process exited with error code.
> systemd[1]: docker.service: Start request repeated too quickly.
> systemd[1]: docker.service: Failed with result 'exit-code'.
> systemd[1]: Failed to start Docker Application Container Engine.
unable to configure the Docker daemon with file /etc/docker/daemon.json: the >
set 22 17:38:26 systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
set 22 17:38:26 systemd[1]: docker.service: Failed with result 'exit-code'.
set 22 17:38:26 systemd[1]: Failed to start Docker Application Container Engine.
set 22 17:38:28 systemd[1]: docker.service: Scheduled restart job, restart counter is at 1.
set 22 17:38:28 systemd[1]: Stopped Docker Application Container Engine.
set 22 17:38:28 systemd[1]: Starting Docker Application Container Engine...
# works
sudo dockerd
sudo dockerd --debug
CodePudding user response:
The issue could be that in /usr/lib/systemd/system/docker.service
there is the line (note fd://
)
ExecStart=/usr/bin/dockerd -H fd://
error:
unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: hosts: (from flag: [fd://], from file: [unix:///var/run/docker.sock tcp://localhost:2375])
CodePudding user response:
[RESOLVED] Exactely, if you configure the /etc/docker/daemon.json configuration file follow the docs:
https://docs.docker.com/engine/reference/commandline/dockerd/
If you configure the hosts fields remove change the ExecStart from the docker.service file > /usr/lib/systemd/system/docker.service
From:
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
To:
ExecStart=/usr/bin/dockerd --containerd=/run/containerd/containerd.sock
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl status docker