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.
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
.
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
[ 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 "storage-driver": "devicemapper"
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.
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