一、正常安装步骤:
第一步:安装必要的一些系统工具
yum install -y yum-utils device-mapper-persistent-data lvm2
第二步:添加软件源信息
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
第三步:更新并安装Docker-CE
yum makecache fast
yum -y install docker-ce
第四步:开启Docker服务
service docker start
第五步、测试是否安装成功
docker -v
二、卸载步骤:
卸载:
1、查询docker安装过的包:
yum list installed | grep docker
? ? ??
2、删除安装包:
yum remove docker-ce.x86_64 ddocker-ce-cli.x86_64 -y
???????????最好是卸载上面列表中三项!
3、删除镜像/容器等
rm -rf /var/lib/docker
?
三、总结下遇到的坑:? ??? ??
(1)docker只支持centos7以上的系统,所以刚开始用了一台centos6.8的服务器失败了,尝试网上各种centos6.8安装docker的方法,耗费时间和精力,还是妥协了,最终重新下载centos7.0,安装后才能装docker
? ? ? ?Docker要求CentOS系统的内核版本高于 3.10 ,通过?uname -r?命令查看你当前的内核版本是否支持安账docker
(2)更新yum包:sudo yum update ,此过程耗时比较大,建议到网速好的地方,也就几分钟时间
(3)遇到的错误bug提示的解决方案:
? ①:错误一: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 sysconfig]# systemctl start docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
?先通过命令:journalctl -xe
显示下面信息
[root@localhost sysconfig]# journalctl -xe 7月 17 01:32:44 localhost.localdomain systemd[1]: docker.service holdoff time over, scheduling restart. 7月 17 01:32:44 localhost.localdomain systemd[1]: Stopped Docker Application Container Engine. -- Subject: Unit docker.service has finished shutting down -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel --? -- Unit docker.service has finished shutting down. 7月 17 01:32:44 localhost.localdomain systemd[1]: Starting Docker Application Container Engine... -- Subject: Unit docker.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel --? -- Unit docker.service has begun starting up. 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.182042254+08:00" level=info msg="Starting up" 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.183338281+08:00" level=info msg="parsed scheme: \"unix\"" module=grpc 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.183424712+08:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.183452777+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock ?<nil> 0 <nil>}] <nil> <nil>}" module=grpc 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.183475821+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.185552912+08:00" level=info msg="parsed scheme: \"unix\"" module=grpc 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.185597605+08:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.185617589+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock ?<nil> 0 <nil>}] <nil> <nil>}" module=grpc 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.185627781+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.190289362+08:00" level=warning msg="Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man dockerd` to refer to dm.thinpooldev section." sto 7月 17 01:32:44 localhost.localdomain systemd-udevd[7514]: inotify_add_watch(7, /dev/dm-3, 10) failed: No such file or directory 7月 17 01:32:44 localhost.localdomain kernel: bio: create slab <bio-2> at 2 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.347615025+08:00" level=info msg="Creating filesystem xfs on device docker-253:1-2381870-base, mkfs args: [-m crc=0,finobt=0 /dev/mapper/docker-253:1-2381870-base]" storage-driver=devicemapper 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.349134553+08:00" level=info msg="Error while creating filesystem xfs on device docker-253:1-2381870-base: exit status 1" storage-driver=devicemapper 7月 17 01:32:44 localhost.localdomain dockerd[7543]: time="2021-07-17T01:32:44.349197227+08:00" level=error msg="[graphdriver] prior storage driver devicemapper failed: exit status 1" 7月 17 01:32:44 localhost.localdomain dockerd[7543]: failed to start daemon: error initializing graphdriver: exit status 1 7月 17 01:32:44 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE 7月 17 01:32:44 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine. -- 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. 7月 17 01:32:44 localhost.localdomain systemd[1]: Unit docker.service entered failed state. 7月 17 01:32:44 localhost.localdomain systemd[1]: docker.service failed. 7月 17 01:32:46 localhost.localdomain systemd[1]: docker.service holdoff time over, scheduling restart. 7月 17 01:32:46 localhost.localdomain systemd[1]: Stopped Docker Application Container Engine. -- Subject: Unit docker.service has finished shutting down -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel --? -- Unit docker.service has finished shutting down. 7月 17 01:32:46 localhost.localdomain systemd[1]: start request repeated too quickly for docker.service 7月 17 01:32:46 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine. -- 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. 7月 17 01:32:46 localhost.localdomain systemd[1]: Unit docker.service entered failed state. 7月 17 01:32:46 localhost.localdomain systemd[1]: docker.service failed.
从上面可以看到报错信息:
最终百度搜索:localhost.localdomain systemd-udevd[7514]: inotify_add_watch(7, /dev/dm-3, 10) failed: No such file or directory
终于得到答案:是因为 xfsprogs 版本太低了。 ?然后命令行输入:yum update xfsprogs
yum update xfsprogs
?然后解决了问题:
?查看上面图即可得知成功了启动了docker
[root@localhost sysconfig]# systemctl start docker
[root@localhost sysconfig]# systemctl enable docker
[root@localhost sysconfig]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since 六 2021-07-17 01:37:50 CST; 1min 51s ago
Docs: https://docs.docker.com
Main PID: 7576 (dockerd)
CGroup: /system.slice/docker.service
└─7576 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
补充一个安装成功标志;
有client和service两部分表示docker安装启动都成功了 !!!
?linux中:没有消息就是好消息,OK!
纸上得来终觉浅,绝知此事要躬行!
|