基于 CentOS 7.8 部署 Docker CE 18.09 的操作步骤

一、部署环境

  • 操作系统:CentOS Linux release 7.8.2003 (Core)
  • 防火墙:关闭
  • SELinux:关闭

二、部署过程

  • 大陆用户换源
rm -rf /etc/yum.repos.d/*.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  • 安装系统工具
yum install yum-utils device-mapper-persistent-data lvm2 -y
  • 配置镜像仓库
yum-config-manager --add-repo  https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  • 清理RPM软件包管理器的缓存索引
yum clean all
  • 重新构建RPM软件包管理器的缓存索引
yum makecache fast
  • 列出仓库中Docker CE的所有版本号
yum list docker-ce --showduplicates
  • 安装Docker CE软件包
yum install docker-ce-18.09.9-3.el7 docker-ce-cli-18.09.9-3.el7 -y
  • 设置Docker CE开机自动启动
systemctl enable docker
  • 启动Docker CE
systemctl start docker
  • 查看Docker CE的状态
systemctl status docker
  • 查看Docker CE的版本
docker version
  • 大陆用户配置镜像仓库加速
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://yln6o2wd.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
  • 拉取“hello-world”镜像
docker pull hello-world
  • 查看本机镜像
docker images
  • 运行测试
docker run hello-world
  • 查看运行完成后的容器
docker ps -a
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容