从0教你Centos 7安装与配置docker

基础配置

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值