centos7安装docker-community

使用存储库安装
1.安装所需的软件包

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

2.使用如下命令设置稳定的存储库

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

3.安装最新版本的docker社区版

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

4.启动docker

systemctl start docker

提示Failed to start docker.service: Unit not found.
docker镜像下载失败
http://ftp.sjtu.edu.cn/centos/7.6.1810/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
解决方法:
1.修改yum源

cd /etc/yum.repos.d/
ll

在这里插入图片描述删除docker-ce.repo

rm -rf docker-ce.repo

添加国内的yum源

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

再次执行安装命令

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

还是提示 404
http://ftp.sjtu.edu.cn/centos/7.6.1810/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
在这里插入图片描述
2.清除yum缓存

yum clean all
rm -rf /var/cache/yum/*

在这里插入图片描述
在这里插入图片描述
再安装docker

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

在这里插入图片描述
在这里插入图片描述
启动docker

systemctl start docker

运行hello-world

docker run hello-world

Unable to find image ‘hello-world:latest’ locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
登录docker

docker login

配置国内镜像站

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io

重启docker服务

service docker restart

运行hello-world容器

 docker run hello-world

在这里插入图片描述
查看容器

docker ps -a

在这里插入图片描述

参考
https://docs.docker.com/install/linux/docker-ce/centos/#install-using-the-convenience-script
https://wiki.centos.org/yum-errors
https://www.daocloud.io/mirror#accelerator-doc

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章