基础配置
1.在华为镜像开源站安装Centos和Epel源,也可以阿里的。
https://mirrors.huaweicloud.com/home
2.在阿里云镜像开源站安装docker-ce源
https://developer.aliyun.com/mirror/
安装常用工具软件
yum install -y tree vim wget bash-completion bash-completion-extras lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telnet bc psmisc httpd-tools bind-utils nethogs expect
docker安装前提
1.需要CentOS 7、CentOS 8或CentOS 9的维护版本。
2.必须启用centos-extras存储库。默认情况下,此存储库是启用的,但是如果您已经禁用了它,则需要重新启用它。
3.建议使用overlay2存储驱动。
卸载老的docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
安装最新的docker
yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
按版本安装docker
1.查看docker版本的列表
[root@Miaojm ~]# yum list docker-ce --showduplicates | sort -r
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable
2.通过docker-ce加版本字符串安装指定版本
#版本字符串是第二列从":"后到"-"的中间数字串
例如:20.10.5
#sudo yum install docker-ce-<版本字符串> docker-ce-cli-<版本字符串> containerd.io docker-compose-plugin
sudo yum install docker-ce-20.10.5 docker-ce-cli-20.10.5 containerd.io docker-compose-plugin
配置Docker 镜像加速
阿里云镜像获取地址:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors,登陆后,左侧菜单选中镜像加速器就可以看到你的专属地址了
按上面网址里面的步骤去配置即可。
启动docker
[root@Miaojm ~]# systemctl enable --now docker.service
测试docker
[root@Miaojm ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:53f1bbee2f52c39e41682ee1d388285290c5c8a76cc92b42687eecf38e0af3f0
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
查看docker版本
[root@Miaojm ~]# docker version
Client: Docker Engine - Community
Version: 20.10.17
API version: 1.41
Go version: go1.17.11
Git commit: 100c701
Built: Mon Jun 6 23:05:12 2022
OS/Arch: linux/amd64
Context: default
Experimental: true