How To Fix Error Starting Docker Service Unit Not Found - Jhooq
How To Fix Error Starting Docker Service Unit Not Found - Jhooq
· Last Modified : Jul 24, 2021 Share on: Author : Rahul Wagh
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 -
BASH
1 systemctl start docker
Incase if you are working on RedHat then you might face this error message -
1 Job for docker.socket failed. See "systemctl status docker.socket" and "journalctl -x
Here are the different ways in which I tried to fix the issue -
Table of Content Home Ansible Kubernetes Terraform YouTube
There is a very high possibility that the version of docker which you running either onto your C
entOS 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.
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.
After removing the old version of docker you must add the latest and correct docker
repository to your yum package manager.
1 sudo yum-config-manager \
2 --add-repo \
3 https://download.docker.com/linux/centos/docker-ce.repo
Now we have removed the old version of docker as well as the added latest version of the
Docker repository to yum package manager.
After installing the docker in the previous step let us start the docker service -
You can now verify the docker installation by running the following docker command -
1 sudo docker run hello-world Home Ansible Kubernetes Terraform YouTube
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.
If the file docker.socket is missing then you can create the file with the following content -
1 [Unit]
2 Description=Docker Socket for the API
3 PartOf=docker.service
4
5 [Socket]
6 ListenStream=/var/run/docker.sock
7 SocketMode=0660
8 SocketUser=root
9 SocketGroup=docker
10
11 [Install]
12 WantedBy=sockets.target
Create and save the file, after that run the following command -
1 systemctl daemon-reload
2 systemctl start docker.socket
3 systemctl start docker
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.
Goto those file locations and enable the docker.service using the following command -
There is one more approach where you need to delete everything from /var/lib/docker using
the following command -
BASH
1 rm -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 -
BASH
1 {
2 "graph": "/mnt/docker-data",
3 "storage-driver": "overlay"
4 }
(*Note - If the daemon.json does not exist
Home then you can create
Ansible the file manually)
Kubernetes Terraform YouTube
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 -
Reference :- Here are some references which I took to consolidate all possible solutions to fix
the issue
Write Preview
Sign in to comment