53

I have installed Docker with yum install docker:

$ uname -a
Linux caspgval4 3.10.0-229.20.1.el7.x86_64 #1 SMP Wed Nov 4 10:08:36 CST 2015 x86_64 x86_64 x86_64 GNU/Linux

$ docker --version
Docker version 1.12.6, build 3a094bd/1.12.6

$ docker info
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: http://docs.docker.com

I am trying to install and run Docker, but it is giving an error as below:

$ sudo service docker start
Redirecting to /bin/systemctl start  docker.service
Failed to start docker.service: Unit not found.

How do I resolve this issue? I tried the following commands, but no luck:

$ sudo systemctl start docker
Failed to start docker.service: Unit not found.

Extra information:

$ journalctl -u docker
No journal files were found.
-- No entries --

$ cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service
Requires=rhel-push-plugin.socket
Requires=docker-cleanup.timer

[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current \
          --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
          --default-runtime=docker-runc \
          --authorization-plugin=rhel-push-plugin \
          --exec-opt native.cgroupdriver=systemd \
          --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
          $OPTIONS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $ADD_REGISTRY \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
MountFlags=slave

[Install]
WantedBy=multi-user.target

I tried the following:

$ sudo systemctl daemon-reload
$ sudo systemctl start docker
Failed to start docker.service: Unit not found.
$ sudo journalctl -u docker
-- No entries --

More debug information:

$ sudo systemctl status network.target
● network.target - Network
   Loaded: loaded (/usr/lib/systemd/system/network.target; static; vendor preset: disabled)
   Active: active since Mon 2017-01-23 02:54:39 PST; 2 months 29 days ago
     Docs: man:systemd.special(7)
           http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget

Jan 23 02:54:39 mymachine systemd[1]: Starting Network.
Jan 23 02:54:39 mymachine systemd[1]: Reached target Network.

$ sudo systemctl status docker-storage-setup.service
● docker-storage-setup.service - Docker Storage Setup
   Loaded: loaded (/usr/lib/systemd/system/docker-storage-setup.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

$ sudo systemctl status rhel-push-plugin.socket
Unit rhel-push-plugin.socket could not be found.

$ sudo systemctl status docker-cleanup.timer
● docker-cleanup.timer - Run docker-cleanup every hour
   Loaded: loaded (/usr/lib/systemd/system/docker-cleanup.timer; disabled; vendor preset: disabled)
   Active: inactive (dead)
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 3
    Have you run `sudo systemctl daemon-reload`? If not, please do so and retry the `sudo systemctl start docker` and `sudo journalctl -u docker` if there are any errors. – BMitch Apr 23 '17 at 19:43
  • Tried and updated the same in the question. –  Apr 23 '17 at 19:46
  • Check your other dependent units with a `sudo systemctl status $x` for network.target, docker-storage-setup.service, rhel-push-plugin.socket, and docker-cleanup.timer. – BMitch Apr 23 '17 at 19:49
  • Updated above details in the question. –  Apr 23 '17 at 19:52
  • If there is any chance you installed `docker-latest` that would be, what blocked me. – Huge Jan 09 '19 at 16:50

10 Answers10

59

Run this command to list all the services:

sudo systemctl list-units --type=service

Look for the correct Docker service name (in my case it is snap.docker.dockerd.service) then run:

sudo systemctl restart snap.docker.dockerd.service
iNSiDER
  • 599
  • 4
  • 2
43

In case someone has installed docker using snap, they can start the service using

sudo snap status docker #check the status
sudo snap start docker # start the service
Amarjit Dhillon
  • 2,718
  • 3
  • 23
  • 62
38

It looks like you're missing the rhel-push-plugin.socket unit which is presumably part of a rhel-push-plugin package. You can try fixing that install, or you can install the upstream Docker package directly from Docker with the following as root:

curl -sSL https://get.docker.com/ | sh

Or more appropriately following the CentOS install guide from Docker. (The CentOS install tends to work on even a RHEL system when you have a supported version, which until the recent 20.10 release did not include CentOS 8 or RHEL 8.)

The upstream Docker install will be a more recent version of Docker, but it will not have the various RHEL modifications like the rhel-push-plugin.

BMitch
  • 231,797
  • 42
  • 475
  • 450
25

Use the following command if your OS is Ubuntu, it will install Docker successfully:

apt install docker.io
Franco
  • 669
  • 2
  • 8
  • 23
6

if you have installed docker with snap you can check the status of the daemon like this:

sudo snap services docker

If the current column shows inactive then it's not running. Try starting it with this:

sudo snap start docker

Check the service again, if it's still not running after that you can check the logs:

sudo snap logs docker

which might give more hints on what's stopping it from running

For me, I had an error saying that docker could not create a symlink in /etc/docker/ because another file was in the way. Emptying the directory was not enough due to a known bug in the docker snap. The work-around was to delete the directory then refresh the snap (see https://forum.snapcraft.io/t/layouts-still-brittle-when-refreshing-snaps/26252/2)

sudo rm -rf /etc/docker
sudo snap refresh
Toby 1 Kenobi
  • 4,717
  • 2
  • 29
  • 43
2

Try to run this command - sudo apt-get install containerd.io docker-ce

It will install containerd runtime and some dependencies for docker.service

Then try to run - sudo systemctl list-units --type=service | grep "docker" You will see docker.service is available

then check status- sudo service docker status

And you're good to go!

1

I worked around the issue by simply doing the following:

$ sudo apt-get purge containerd.io docker-ce
$ rm -rf /var/lib/containerd
[reboot]
$ sudo apt-get install containerd.io docker-ce
emre avci
  • 11
  • 2
-1

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html

Note

In some cases, you may need to reboot your instance to provide permissions for the ec2-user to access the Docker daemon. Try rebooting your instance if you see the following error:

zuyao88
  • 64
  • 8
-1

In Ubuntu, the following command works for me:

sudo apt install docker.io

Welemhret
  • 44
  • 5
  • Please explain why this will help. Also, please read [how to answer](https://stackoverflow.com/help/how-to-answer) – pierpy May 21 '23 at 08:27
-5

Try installing Docker as root (sudo):

sudo yum install docker

See Installation on Red Hat Enterprise Linux.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Siva
  • 3
  • 1