1. Uninstall Docker. If the old Docker is not successfully installed, uninstall it directly.

(1) view of installation package: yum list installed | grep docker

X86_64, docker-client.x86_64, docker-common.x86_64

(2) Delete the installed Docker-related software package:

             yum -y remove docker.x86_64

             yum -y remove docker-client.x86_64

             yum -y remove docker-common.x86_64

Install command

67 yum install -y yum-utils device-mapper-persistent-data lvm 68 yum-config-manager –add-repo Mirrors.aliyun.com/docker-ce/l… 69 yum makecache fast 70 yum -y install docker-ce 71 systemctl start docker 72 docker run hello-world 73 systemctl status docker 74 systemctl stop docker 75 systemctl status docker 76 systemctl restart docker 77 systemctl status docker 78 cd /etc/docker 83 ls -a 84 vim daemon.json 85 yum remove docker-ce 86 rm -rf /var/lib/docker \

CentOS Docker installation

Docker supports the following CentOS versions:

  • CentOS 7 (64-bit)
  • CentOS 6.5 (64-bit) or later
The premise condition

Currently, CentOS only supports Docker kernels in distributions. Docker runs on CentOS 7. The operating system must be 64-bit and the kernel version must be at least 3.10. 2. Docker runs on CentOS 6.5 or later, which must be 64-bit and have a kernel version of 2.6.32-431 or later.

Yum install (CentOS 7)

Docker requires a CentOS kernel version later than 3.10. Check the prerequisites on this page to verify that your CentOS version supports Docker.

Check your current kernel version with the uname -r command

支那

[root@localhost ~]# uname -r
Copy the code

Kernel version

Since March 2017, Docker has been divided into two branch versions: Docker CE and Docker EE. Docker CE is the community free edition, Docker EE is the enterprise edition, emphasis on security, but pay to use.

This article introduces the installation and use of Docker CE.

Remove the old version:

支那

$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine
Copy the code

Install the necessary system tools:

支那

yum install -y yum-utils device-mapper-persistent-data lvm2
Copy the code

Adding software source information:

支那

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Copy the code

Update the yum cache:

支那

yum makecache fast
Copy the code

Install docker-ce :(takes a bit longer)

支那

yum -y install docker-ce
Copy the code

Start the Docker background service

支那

systemctl start docker
Copy the code

The test runs hello-world

支那

docker run hello-world
Copy the code

Run the mirror

Since there is no local hello-world image, a hello-world image is downloaded and run inside the container.

Check the docker status

支那

systemctl status docker
Copy the code

The docker state

Close the docker

支那

systemctl stop docker
Copy the code

Close the docker

Restart the docker

支那

systemctl restart docker
Copy the code

Restart the success

Mirror to accelerate

In view of the domestic network problems, it is very slow to pull the Docker image, so we need to configure the accelerator to solve it. I used the mirror address of netease: hub-mirror.c.163.com. New versions of Docker use /etc/dock/daemon. json to configure daemons.

Please add it to the configuration file (if you don’t have one, please create one first) :

支那

{
  "registry-mirrors": ["http://hub-mirror.c.163.com"]
}
Copy the code

Delete the Docker CE

Execute the following command to remove the Docker CE:

支那

$ yum remove docker-ce
$ rm -rf /var/lib/docker
Copy the code

Failed to start docker Application Container Engine.

Restart the Docker service

Here’s the solution

To view the daemon. Json

cat /etc/docker/daemon.json
Copy the code

cd /etc/docker/daemon.json

Docker container accelerator is a daemon. Json container accelerator, which is designed to pull images faster

Be sure to indent

Demon. json file can be indent, but cannot be blank

Successful solution!