centos7 install docker

Docker adopts the timeline method as the version number since version 1.13, divided into community version CE and enterprise version EE.

The community version is free for individual developers and small groups to use, and the enterprise version will provide additional paid services, such as infrastructure, containers, and plug-ins that have been officially tested and certified.

The community version is released in two ways: stable and edge. The stable version is updated quarterly, such as 17.06, 17.09; the edge version is updated every month, such as 17.09, 17.10.

One, install docker

1、 Docker requires the kernel version of the CentOS system to be higher than 3.10. Check the prerequisites on this page to verify whether your CentOS version supports Docker.

View your current kernel version through the uname -r command

$ uname -r

2、 Log in to Centos with root privileges. Ensure that the yum package is updated to the latest. (Be cautious, it may cause other software packages to be unavailable)

Don’t yum update casually. The consequences will sometimes cause the system to fail to boot, because it will update your kernel. If the update fails, yum clean all is best.

$ sudo yum update

3、 Uninstall the old version (if the old version is installed)

$ sudo yum remove docker  docker-common docker-selinux docker-engine

4、 Install the required software packages, yum-util provides yum-config-manager function, and the other two are dependent on the devicemapper driver

$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

5、 Set yum source

$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

6、 You can view all docker versions in all warehouses and select a specific version to install

$ yum list docker-ce --showduplicates | sort -r

7、 Install docker

$ sudo yum install docker-ce  #Since only the stable warehouse is opened by default in the repo, the latest stable version 17 is installed here.12.0 
$ sudo yum install <FQPN>  #For example: sudo yum install docker-ce-17.12.0.ce

7.1 Change the mirror source of docker

After installation, change the docker mirror source, modify or add /etc/docker/daemon.json

vi /etc/docker/daemon.json
Amended as follows:

{" registry-mirrors":["http://hub-mirror.c.163.com"]}
or
{" registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]}

8、 Start and add startup

$ sudo systemctl start docker
$ sudo systemctl enable docker

Service start, stop, check, restart

service docker start/stop/status/restart
chkconfig docker on

9、 Verify that the installation is successful (there are two parts, client and service, indicating that the docker installation and startup are successful)

$ docker version

Test run hello-world

[ root@runoob ~]#docker run hello-world

Since there is no hello-world image locally, a hello-world image will be downloaded and run in the container.

10、 other
List all local mirrors

docker images

Delete local mirror

docker rmi centos

If there is already a container based on this image, you need to delete the corresponding container before deleting the image. Or use the -f parameter to force the deletion of the mirror, such as docer rmi -f centos.

Second, the problem##

1、 Because the old version of docker has been installed before, the following error was reported during installation:

Transaction check error:
 file /usr/bin/docker from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file frompackage docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
 file /usr/bin/docker-containerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file frompackage docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
 file /usr/bin/docker-containerd-shim from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file frompackage docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
 file /usr/bin/dockerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file frompackage docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

2、 Uninstall the old version of the package

$ sudo yum erase docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

Uninstall Docker CE

[ root@centos_7 ~]# sudo yum remove docker-ce 
[ root@centos_7 ~]#  sudo rm -rf /var/lib/docker

3、 Install docker again

$ sudo yum install docker-ce

Cannot start normally

[ root@test ~]# service docker start

Redirecting to /bin/systemctl start  docker.service

Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe"for details.[root@localhost plugins]# journalctl -xe
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: time="2018-05-17T15:11:13+08:00" l
5 Month 1715:11:13 localhost.localdomain dockerd[10864]: Error starting daemon: error initi
5 Month 1715:11:13 localhost.localdomain systemd[1]: docker.service: main process exited, c
5 Month 1715:11:13 localhost.localdomain systemd[1]: Failed to start Docker Application Con
- - Subject: Unit docker.service has failed
- - Defined-By: systemd
- - Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
- - - - Unit docker.service has failed.---- The result is failed.May 1715:11:13 localhost.localdomain systemd[1]: Unit docker.service entered failed sta
5 Month 1715:11:13 localhost.localdomain systemd[1]: docker.service failed.5Month 1715:11:13 localhost.localdomain systemd[1]: docker.service holdoff time over, sche
5 Month 1715:11:13 localhost.localdomain systemd[1]: start request repeated too quickly for5Month 1715:11:13 localhost.localdomain systemd[1]: Failed to start Docker Application Con
- - Subject: Unit docker.service has failed
- - Defined-By: systemd
- - Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
- - - - Unit docker.service has failed.---- The result is failed.May 1715:11:13 localhost.localdomain systemd[1]: Unit docker.service entered failed sta
5 Month 1715:11:13 localhost.localdomain systemd[1]: docker.service failed.[root@localhost packages]# systemctl status docker.service -l
● docker.service - Docker Application Container Engine
 Loaded:loaded(/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
 Active:failed(Result: start-limit)since April 2018-05-1714:55:09 CST; 7min ago
  Docs: https://docs.docker.com
 Process:9940 ExecStart=/usr/bin/dockerd(code=exited, status=1/FAILURE)
 Main PID:9940(code=exited, status=1/FAILURE)May 1714:55:09 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.May 1714:55:09 localhost.localdomain systemd[1]: Unit docker.service entered failed state.May 1714:55:09 localhost.localdomain systemd[1]: docker.service failed.May 1714:55:09 localhost.localdomain systemd[1]: docker.service holdoff time over, scheduling restart.May 1714:55:09 localhost.localdomain systemd[1]: start request repeated too quickly for docker.service
5 Month 1714:55:09 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.5Month 1714:55:09 localhost.localdomain systemd[1]: Unit docker.service entered failed state.5Month 1714:55:09 localhost.localdomain systemd[1]: docker.service failed.

Check the file system /etc/docker/daemon.json to see if there is this file, and it is not tested to create it including the secondary directory docker
Enter the following in the daemon.json file:

[ root@localhost plugins]# vi /etc/docker/daemon.json
{" graph":"/mnt/docker-data","storage-driver":"devicemapper","registry-mirrors":["http://hub-mirror.c.163.com"]}

My problem is to add &quot;storage-driver&quot;: &quot;devicemapper&quot; to solve


Install Docker using script
1、 Log in to Centos with sudo or root privileges.
2、 Ensure that the yum package is updated to the latest. (Be cautious, it may cause other software packages to be unavailable)

$ sudo yum update

3、 Execute the Docker installation script.

$ curl -fsSL https://get.docker.com/| sh

Executing this script will add the docker.repo source and install Docker.

4、 Start the Docker process.

$ sudo service docker start

5、 Verify that docker is installed successfully and execute a test image in the container.

$ sudo docker run hello-world
docker ps

At this point, the installation of docker in CentOS system is complete.

Mirror acceleration

In view of the domestic network problems, the subsequent pull of the Docker image is very slow. We may need to configure the accelerator to solve it. I use the NetEase mirror address: http://hub-mirror.c.163.com.
The new version of Docker uses /etc/docker/daemon.json (Linux) or %programdata%\docker\config\daemon.json (Windows) to configure Daemon.
Please add it to the configuration file (if there is no such file, please create one first):

# If there is no such file, create a new one
vi /etc/docker/daemon.json

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

Reference: http://www.runoob.com/docker/centos-docker-install.htmlhttps://www.cnblogs.com/yufeng218/p/8370670.htmlhttp://blog.cheyo.net/280.html

Question reference: https://www.cnblogs.com/amoyzhu/p/5261393.htmlhttps://blog.csdn.net/qq_35904833/article/details/74189383https://www.oschina.net/question/988854_2143631

Recommended Posts

CentOS 7 install Docker
CentOS7 install Docker
Centos7 install Docker
Centos7 install docker18
centos7 install docker
CentOS 6 install Docker
Centos8 install Docker
Install Docker on Centos7
CentOS 7 install Docker service
CentOS 8-dnf install docker
install Docker on centos6.5
CentOS 7 install Docker CE
1.5 Install Centos7
Install docker transfer on Centos7
Install docker on Centos system
Centos6 install Python2.7.13
Centos7.3 install nginx
CentOS7.2 install Mysql5.7.13
Centos7 install Python 3.6.
CentOS7 install MySQL
Centos7 install protobuf
CentOS7 install GlusterFS
ubuntu18.04 install docker
Centos6.5 install Tomcat
CentOS install Python 3.6
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Install MySql with Docker in CentOS7
Centos7 install Python2.7
Centos 7.6 install seleniu
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
CentOS install mysql
Docker installation (CentOS7 installation)
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
Container study notes CentOS7 install Docker
CentOS7 install mysql
centOs install rabbitMQ
CentOS 7 install MySQL 5.6
Install and use docker under CentOS 6.8
docker install ubuntu
Centos7 install Nginx
CentOS6.5 install CDH5.13
Install Centos7 operating system in Docker
Centos install Python3
CentOS install jdk
centos7 install nginx-rtmp
CentOS8 install MySQL8.0
Centos6.3 install KVM
CentOS install PostgreSQL 9.1
CentOS7 install mysql8
CentOS7 docker installation
CentOS 7 install Java 1.8
CentOS8 install fastdfs6.06
CentOS 7 install Gitlab
Centos 7 install PostgreSQL
CentOS7 install MySQL8