docker安装

1、卸载之前的docker

sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine

2、安装必要的依赖

sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2

3、设置docker仓库

sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

4、设置镜像加速器

访问这个地址,使用自己的阿里云账号登录,查看菜单栏左下角,发现有一个镜像加速器:

https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors

命令如下:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://xxxxxxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

5、 安装docker

sudo yum install -y docker-ce docker-ce-cli containerd.io

6 、启动docker

sudo systemctl start docker

7、测试docker安装是否成功

sudo docker run hello-world

8、遇到问题解决

8.1、Error: Package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.aliyun.com
 * centos-sclo-sclo: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.4.8-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.4.8-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.7-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-20.10.7-3.el7.x86_64
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.7-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.7-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.7-3.el7.x86_64
--> Running transaction check
---> Package containerd.io.x86_64 0:1.4.8-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.4.8-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.7-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-20.10.7-3.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:20.10.7-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64
---> Package docker-scan-plugin.x86_64 0:0.8.0-3.el7 will be installed
--> Finished Dependency Resolution
Error: Package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64 (docker-ce-stable)
           Requires: fuse-overlayfs >= 0.7
Error: Package: 3:docker-ce-20.10.7-3.el7.x86_64 (docker-ce-stable)
           Requires: container-selinux >= 2:2.74
Error: Package: containerd.io-1.4.8-3.1.el7.x86_64 (docker-ce-stable)
           Requires: container-selinux >= 2:2.74
Error: Package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64 (docker-ce-stable)
           Requires: slirp4netns >= 0.4
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
解决方案
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum -y install docker-ce
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值