Docker Service Error – Fixing ‘Unit Not Found’ Error When Starting Docker

dockerrhelsocket

I am working with a Redhat 7.4, this machine doesn't have internet connection, and I want to install Docker, therefore I downloaded a rpm package, this one:

docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm

I used the command yum install and apparently all the process went fine but my issue begins when I use sudo systemctl start docker I get this:

Failed to start docker.service: Unit not found.

I tried the solution in this topic: Cannot start docker daemon in CentOS7 | Stack Overflow and my issue wasn't solved, I wrote this in the document docker.socket

[Unit]
Description=Docker Socket for the API
PartOf=docker.service

[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker

[Install]
WantedBy=sockets.target

when using the command sudo systemctl start docker.socket it throws this:

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

Then I used this command sudo systemctl status docker.socket and got this

docker.socket - Docker Socket for the API
Loaded: loaded (/usr/lib/systemd/system/docker.socket; disabled; vendor 
preset: disabled)
Active: inactive (dead)
Listen: /var/run/docker.sock (Stream)

mar 02 10:19:28 machine.name systemd[1]: Socket service 
docker.service not loaded, refusing.
mar 02 10:19:28 machine.name systemd[1]: Failed to listen on Docker 
Socket for the API.

This is what I get when using journalctl -xe

No journal files were found.
-- No entries --

I am all stuck in this issue and I don't know what else to do/try; I am a bit new with Linux therefore I might be missing something.

EDIT 1

I've tried the command rpm -qa | grep docker and this is what I got:

docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch

Best Answer

If you must install a Centos package on RHEL then the package that you actually want is:

docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm

You can download it elsewhere and then bring it over to your machine. The link to the package is 'https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm`

You will also need the package: container-selinux-2.36-1.gitff95335.el7.noarch.rpm as it is a dependency. It can be obtained from http://mirror.centos.org/centos/7/extras/x86_64/Packages/

Before you begin, either yum remove docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm or rpm -e docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm as they may conflict with container-selinux-2.36-1.gitff95335.el7.noarch.rpm

After the packages I mentioned are on your machine, you can install them one of two ways:

yum install container-selinux-2.36-1.gitff95335.el7.noarch.rpm docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm

rpm -ivh container-selinux-2.36-1.gitff95335.el7.noarch.rpm docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm

After installation,

systemctl list-unit-files | grep docker which will show docker.service

systemctl enable docker

systemctl start docker

systemctl status docker

You will see the docker service started and running.

Related Question