Centos 7 安装 Docker
- 安装 yum 仓库配置工具和 Docker 存储依赖
yum install -y yum-utils \ device-mapper-persistent-data \ lvm2
- 安装 Docker yum 仓库
yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
- 安装 Docker
yum install -y docker-ce docker-ce-cli containerd.io
- 注册 Docker 服务,开机自动启动
systemctl enable docker systemctl restart docker
- 配置 Docker , registry-mirrors 指定使用国内镜像仓库
mkdir -p /etc/docker cat <<EOF > /etc/docker/daemon.json { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "storage-driver": "overlay2", "storage-opts": [ "overlay2.override_kernel_check=true" ], "registry-mirrors" : [ "https://registry.docker-cn.com" ] } EOF systemctl daemon-reload systemctl restart docker
- 测试 Docker 是否安装成功
docker run hello-world