How to fix Error starting docker service Unit not found?

In this blog post, we will look at the different ways to fix the Error starting docker service Unit not found.

I faced this issue while I was trying to set up Kubernetes cluster on CentOS 8. As Kubernetes is a container orchestration tool and it is used for managing container images, so I had to install Docker before installing the Kubernetes cluster.

But after installing the Docker when I executed the following command -

1systemctl start docker 

I immediately faced the following error on my CentOS machine -

1Failed to start docker.service: Unit not found.

Incase if you are working on RedHat then you might face this error message -

1Job for docker.socket failed. See "systemctl status docker.socket" and "journalctl -xe" for details. 

Here are the different ways in which I tried to fix the issue -

Table of Content

  1. Re-install the latest version of docker
  2. Add missing docker.socket
  3. Enable docker.service
  4. Configure docker daemon to use overlay storage drive

1. Re-install the latest version of docker

There is a very high possibility that the version of docker which you running either onto your CentOS or RedHat machine is not supported and this is what happened with me.

I just randomly installed docker onto my CentOS machine. Installation went pretty smooth but when I tried starting docker systemctl start docker I noticed it can not find the docker.service .

After some time spending time on google and searching solutions on the forums I decided to remove all the docker container and do a fresh installation of the docker. But this time I referred to the official guide of docker for installation.

And here are the steps which I followed after that -

1. Uninstall old version of docker -

The first important step is to remove the previous docker installation and all the docker components such as - docker-engine, docker-client, docker-common, docker-logrotate etc.

Here is the command for removal -

1sudo yum remove docker \
2docker-client \
3docker-client-latest \
4docker-common \
5docker-latest \
6docker-latest-logrotate \
7docker-logrotate \

2. Add docker repository to Yum package manage

After removing the old version of docker you must add the latest and correct docker repository to your yum package manager.

1sudo yum install -y yum-utils 
1sudo yum-config-manager \
2    --add-repo \

3. Install Docker engine

Now we have removed the old version of docker as well as the added latest version of the Docker repository to yum package manager.

Now its time for installing the docker -

1sudo yum install docker-ce docker-ce-cli

4. Start Docker service

After installing the docker in the previous step let us start the docker service -

1sudo systemctl start docker 

5. Verify the docker installation

You can now verify the docker installation by running the following docker command -

1sudo docker run hello-world

2. Add missing docker.socket

If you have done the installation of docker as described in the Step-1 but still struggling with the issue Failed to start docker.service: Unit not found. then I would recommend checking the docker.socket file.

You can find this file at location - /usr/lib/systemd/system/docker.socket

If the file docker.socket is missing then you can create the file with the following content -

 2Description=Docker Socket for the API

Create and save the file, after that run the following command -

1systemctl daemon-reload
2systemctl start docker.socket
3systemctl start docker  

You docker service should start after this.

3. Enable docker.service

This solution is a little trivial because at first glance you will notice everything (docker installtion, docker.socket) which you did is correct but still you are getting the error Failed to start docker.service: Unit not found.

In such a cases the docker.socket file should be either at /lib/systemd/system or /etc/systemd/system.

Goto those file locations and enable the docker.service using the following command -

1sudo systemctl enable docker.service 

4. Configure docker daemon to use overlay storage drive

There is one more approach where you need to delete everything from /var/lib/docker using the following command -

1rm -rf /var/lib/docker 

After removing everything from the /var/lib/docker you need to set docker daemon to use overlay driver.

You need to update the flag inside /etc/docker/daemon.json. Here is the content of the flag -

2    "graph": "/mnt/docker-data",
3    "storage-driver": "overlay"

(*Note - If the daemon.json does not exist then you can create the file manually)

Now you can restart the docker service and it should work fine.

Also if you want the docker service to start at the boot time instead of manually then you can set the following -

1 sudo systemctl enable docker.service
2 sudo systemctl enable containerd.service  

Reference :- Here are some references which I took to consolidate all possible solutions to fix the issue

  1. Stackoverflow - Cannot start docker daemon in CentOS7
  2. Unix Stackexchange - Error starting docker service: Unit not found

Posts in this series