CentOS 安装 Docker(国内镜像站)

准备

适用于 CentOS 7+

# 首先卸载旧版本。(如果安装过旧版本的话)
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

# 删除 `docker-ce` (包括镜像、容器、宗卷和网络)
rm -rf /var/lib/docker/

安装

本次教程将使用从 yum 安装。

首次安装需要设置 Docker 存储库,用来安装和更新 Docker。

# 下载 Docker 存储库
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo

# 设置存储库为国内镜像站。(这里已腾讯镜像站为例)
sudo sed -i 's+download.docker.com+mirrors.cloud.tencent.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo

# 然后建立缓存。(提高安装速度)
sudo yum makecache

然后执行以下命令进行安装。

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

如果提示接受GPG密钥,请验证指纹是否匹配,确认后输入 y 回车可继续安装。
060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35

等待安装完成即可。

  • docker-ce - Docker daemon, this is the part that does all the management work, requires the other two on Linux.
  • docker-ce-cli - CLI tools to control the daemon, you can install them on their own if you want to control a remote Docker daemon.
  • containerd.io - daemon to interface with the OS API (in this case, LXC - Linux Containers), essentially decouples Docker from the OS, also provides container services for non-Docker container managers.

启动

sudo systemctl start docker

验证

通过运行 hello-world 镜像来验证 Docker 引擎是否正确安装。

sudo docker run hello-world

参考地址:https://docs.docker.com/engine/install/centos/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值