📅  最后修改于: 2023-12-03 15:08:47.597000             🧑  作者: Mango
Docker-CE 是一个流行的开源容器化平台,可以构建、部署和管理容器。本文将介绍如何在 Redhat 8 中安装 Docker-CE。
在开始安装 Docker-CE 之前,需要确认你的系统符合以下要求:
如果你之前安装过 Docker 的旧版本,需要先将其卸载:
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
安装 Docker-CE 前需要先安装依赖项:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
执行以下命令将 Docker 仓库添加到 yum 软件源:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
执行以下命令安装 Docker-CE:
sudo yum install docker-ce docker-ce-cli containerd.io
安装完成后启动 Docker 服务:
sudo systemctl start docker
运行以下命令来确保 Docker 服务已正确启动:
sudo systemctl status docker
你将看到一条类似以下内容的消息:
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2021-08-23 10:05:19 CST; 1h 34min ago
Docs: https://docs.docker.com
Main PID: 15392 (dockerd)
Tasks: 72
Memory: 161.6M
CGroup: /system.slice/docker.service
├─15392 /usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375
└─15402 docker-containerd --config /var/run/docker/containerd/containerd.toml --log-level info
Aug 23 10:05:18 cheungTCL01 systemd[1]: Starting Docker Application Container Engine...
Aug 23 10:05:19 cheungTCL01 dockerd[15392]: time="2021-08-23T10:05:19.166732705+08:00" level=warning msg="Your kernel does not support cgroup swapp...aceships."
Aug 23 10:05:19 cheungTCL01 dockerd[15392]: time="2021-08-23T10:05:19.167868959+08:00" level=warning msg="Your kernel does not support cgroup swapp...aceships."
Aug 23 10:05:19 cheungTCL01 dockerd[15392]: time="2021-08-23T10:05:19.169491474+08:00" level=info msg="Loading containers: start."
Aug 23 10:05:19 cheungTCL01 dockerd[15392]: time="2021-08-23T10:05:19.609926730+08:00" level=info msg="Default bridge (docker0) is assigned with ...ddress"
Aug 23 10:05:19 cheungTCL01 dockerd[15392]: time="2021-08-23T10:05:19.661891050+08:00" level=info msg="Loading containers: done."
Aug 23 10:05:19 cheungTCL01 systemd[1]: Started Docker Application Container Engine.
设置 Docker 开机启动:
sudo systemctl enable docker
安装 Docker-CE 可以使用以下命令:
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo systemctl status docker
sudo systemctl enable docker
现在你已经成功在 Redhat 8 中安装了 Docker-CE,可以开始使用容器了!