centos7.6 安装docker
参考:https://docs.docker.com/install/linux/docker-ce/centos/
一.存在老版本先删除
yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
二.(安装依赖)Install required packages. yum-utils
provides the yum-config-manager
utility, and device-mapper-persistent-data
and lvm2
are required by the devicemapper
storage driver.
$ yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
三.(配置官方源)Use the following command to set up the stable repository.
$ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
四.更新yum包索引
yum makecache fast
五.安装Docker CE
yum install docker-ce -y
六.启动
systemctl start docker
七.卸载
yum -y remove docker-ce
rm -rf /var/lib/docker
八.安装结果验证 docker info
官方测试:sudo docker run hello-world
配置文件: /etc/sysconfig/docker
存储位置: /var/lib/docker
九. 配置Docker加速器
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
sudo systemctl restart docker
十. 备注:错误汇总
1.配置官方源报错
$ sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
错误信息如下:
Timeout on https://download.docker.com/linux/centos/docker-ce.repo: (28, 'Operation timed out after 30034 milliseconds with 0 out of 0 bytes received')
错误原因:由于国内访问不到docker官方镜像的缘故
解决方法:修改国内阿里云地址即可
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
2.内核版本过低报错
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:293: copying bootstrap data to pipe caused \"write init-p: broken pipe\"": unknown.
参考升级内核:https://blog.csdn.net/kikajack/article/details/79396793
如果有问题可以加我微信(baolongsj)共同学习和进步…..