本文主要是介绍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
这篇关于centos7安装docker-community的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!