How to fix the Error starting docker service Unit not found?
Ankit Kumar
Aspiring Cloud & DevOps Engineer | Python | C/C++ | FastAPI | Docker | Terraform.
After installing the Docker when I executed the following command -
1systemctl start docker
BASH
I immediately faced the following error on my CentOS machine -
1Failed to start docker.service: Unit not found.
In case 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 is how I tried to fix the issue -
Re-install the latest version of the 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 smoothly but when I tried starting the docker systemctl start docker I noticed it can not find the docker.service .
And here are the steps that I followed after that -
Uninstall the 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 \
8docker-engine
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 https://download.docker.com/linux/centos/docker-ce.repo
3. Install Docker engine
Now we have removed the old version of Docker as well as added the latest version of the Docker repository to yum package manager.
Now its time to install the docker -
1sudo yum install docker-ce docker-ce-cli containerd.io
4. Start the 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