一、docker 安装配置
1、安装依赖环境
yum -y install yum-utils device-mapper-persistent-datalvm2
2、设置一下docker镜像源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3、安装docker
缓存一下软件包,提高搜索安装软件的速度
yum makecache fast
开始安装docker
ce是社区版本 ee 企业版本, 这里我们安装社区版本 来做演示和学习
yum install docker-ce docker-ce-cli containerd.io
已安装:
containerd.io.x86_64 0:1.6.20-3.1.el7 docker-ce.x86_64 3:23.0.4-1.el7 docker-ce-cli.x86_64 1:23.0.4-1.el7
作为依赖被安装:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 docker-buildx-plugin.x86_64 0:0.10.4-1.el7 docker-ce-rootless-extras.x86_64 0:23.0.4-1.el7 docker-compose-plugin.x86_64 0:2.17.2-1.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8
作为依赖被升级:
libselinux.x86_64 0:2.5-15.el7 libselinux-python.x86_64 0:2.5-15.el7 libselinux-utils.x86_64 0:2.5-15.el7 libsemanage.x86_64 0:2.5-14.el7 libsemanage-python.x86_64 0:2.5-14.el7 libsepol.x86_64 0:2.5-10.el7 policycoreutils.x86_64 0:2.5-34.el7 policycoreutils-python.x86_64 0:2.5-34.el7
selinux-policy.noarch 0:3.13.1-268.el7_9.2 selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2 setools-libs.x86_64 0:3.3.8-4.el7
完毕!
出现这些说明安装完成
启动docker服务
systemctl start docker
设置开机自启动
systemctl enable docker
测试docker运行
docker run hello-world
出现这些 说明docker成功安装
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
4、docker的卸载
yum remove docker-ce docker-ce-cli containerd.io
删除工作路径的文件 默认工作路径是 /var/lib/docker
需要执行rm命令把这个工作路径删除
5、docker配置阿里云镜像加速
在/etc/docker目录下新增daemon.json文件编辑阿里镜像地址:
{
"stry-mirrors": ["https://78q96cy9.mirror.aliyuncs.com"]
}
重启镜像和docker服务
systemctl daemon-reload
systemctl restart docker
重启docker时遇到以下问题:
[root@k8s-node01 docker]# systemctl restart docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
解决: 修改 /etc/daemon.json文件
[root@k8s-node01 docker]# mv daemon.json daemon.conf
再次重启就正常了

浙公网安备 33010602011771号