本机虚拟机安装docker老是报错,后来放弃了,直接在云服务器上干了 三个阶段
- Linux系统 CentOS 7
- docker安装教程
- 阿里云镜像加速
所有操作切换进入root权限 cd /
安装
查看本机版本 仅支持3.10版本以及以上
[root@instance-z42b1xb1 /]# uname -a Linux instance-z42b1xb1 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
进行yum 更新
[root@instance-z42b1xb1 /]# yum update
卸载旧版本(如果安装过旧版本的话)
[root@instance-z42b1xb1 /]# yum remove docker docker-common docker-selinux docker-engine
安装 applydeltarpm
yum provides '*/applydeltarpm' yum install deltarpm -y
设置yum源头
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo(中央仓库) yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo(阿里仓库)
查看所有仓库中所有docker版本
yum list docker-ce --showduplicates | sort -r
安装Docker
yum install docker-ce-版本号
启动Docker
systemctl start docker
加入开机启动
systemctl enable docker
检查版本
[root@instance-z42b1xb1 /]# docker version Client: Docker Engine - Community Version: 19.03.8 API version: 1.40 Go version: go1.12.17 Git commit: afacb8b Built: Wed Mar 11 01:27:04 2020 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.8 API version: 1.40 (minimum version 1.12) Go version: go1.12.17 Git commit: afacb8b Built: Wed Mar 11 01:25:42 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.13 GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc: Version: 1.0.0-rc10 GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd docker-init: Version: 0.18.0 GitCommit: fec3683 [root@instance-z42b1xb1 /]#
只能说安装成功,并且启动成功。但是还要查一遍
检查端口是否正常运行
[root@instance-z42b1xb1 /]# ps -ef|grep docker root 10232 1 0 01:25 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock root 10757 14574 0 01:52 pts/0 00:00:00 grep --color=auto docker
设置阿里云镜像加速 红色方框脚本语句,直接复制粘贴,直接运行就行了
运行 hello-world 本地没有找个镜像,会去仓库找,本地仓库没有就会***库下拉
就如同maven一样,本地没有的依赖会去maven库下载,下次再用直接读本地依赖,就是找个原理
[root@instance-z42b1xb1 /]# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 0e03bdcc26d7: Pull complete Digest: sha256:8e3114318a995a1ee497790535e7b88365222a21771ae7e53687ad76563e8e76 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
真正意义上的安装,配置,运行,完成
- 安装会很慢,不要认为它卡了,或者死机了
- 如果安装出现error,faild这些tag,就说明出问题了,直接卸载重装,别浪费时间
卸载docker
查询安装过的软件包
[root@instance-z42b1xb1 /]# yum list installed | grep docker containerd.io.x86_64 1.2.13-3.1.el7 @docker-ce-stable docker-ce.x86_64 3:19.03.8-3.el7 @docker-ce-stable docker-ce-cli.x86_64 1:19.03.8-3.el7 @docker-ce-stable
卸载安装的软件包
yum -y remove docker-ce.x86_64 ddocker-ce-cli.x86_64 -y
删除存储目录
rm -rf /etc/docker rm -rf /run/docker rm -rf /var/lib/dockershim rm -rf /var/lib/docker
如果发现删除不掉,需要先 umount
umount /var/lib/docker/devicemapper