First of all, your Centos system must be 64-bit, regardless of the version. And the kernel version is at least 3.10 or higher.
Use the following command to check your kernel version:
uname -r
3.10.0-229.el7.x86_64
Log in to the system as a user with sudo or root privileges.
Make sure your yum package has been updated.
sudo yum update
Add yum repo:
sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
Add the following content:
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
Finish and press Enter
sudo yum install docker-engine
[root@docker-node1 ~]# systemctl start docker.service
At this point, the installation of docker on the CentOS system is complete.
The verification is successful:
[root@dtc ~]# docker version
message when successful:
Client:
Version: 18.09.5
API version: 1.39
Go version: go1.10.8
Git commit: e8ff056
Built: Thu Apr 11 04:43:34 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.5
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: e8ff056
Built: Thu Apr 11 04:13:40 2019
OS/Arch: linux/amd64
Experimental: false
[root@dtc ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@dtc ~]#
[root@dtc ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
[root@dtc ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest fce289e99eb9 3 months ago 1.84kB
Here hello-world has appeared and succeeded.
Cannot connect to the Docker daemon at tcp://0.0.0.0:2375. Is the docker dae...
The management port is in the /lib/systemd/system/docker.service
file
Replace ExecStart=/usr/bin/dockerd
with:
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -H tcp://0.0.0.0:7654
(Here, by default, 2375
is the main management port, unix:///var/run/docker.sock
is used for local management, and 7654
is the alternate port)
Write management address to /etc/profile
echo 'export DOCKER_HOST=tcp://0.0.0.0:2375' >> /etc/profile
Warning: docker.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Execute according to the prompt: systemctl daemon-reload
Then restart: systemctl restart docker.service