CentOS7.9 安装 Docker
- Linux
- 2025-02-08
- 38热度
- 0评论
1、安装需要的软件包,yum-util 提供 yum-config-manager 功能,另外两个是 devicemapper 驱动依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
2、设置yum源(选择其中一个)
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo(中央仓库)
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo(阿里仓库)
3、安装(开源社区版本)
yum -y install docker-ce
4、启动docker并加入开机启动
systemctl start docker
systemctl enable docker
5、查看安装的版本
docker version
6、测试hello-world(需要FQ,可能会拉取不下来)
docker pull hello-world
7、运行 hello-world
docker run hello-world
8、编辑 /etc/docker/daemon.json(如果以下地址失效请自行找有效地址)
vim /etc/docker/daemon.json
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn",
"https://docker-proxy.741001.xyz",
"https://registry.docker-cn.com"
]
}
9、重新加载配置,并重新启动 docker,再次拉取 hello-world 即可
systemctl daemon-reload
systemctl restart docker

鲁ICP备19063141号
鲁公网安备 37010302000824号