CentOS8安装Docker

  • 切换到root

    su

    输入密码

  • 安装基础包

    1
    2
    3
    yum install -y yum-utils
    yum install -y device-mapper-persistent-data
    yum install -y lvm2
  • 设置稳定仓库

    yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

  • 安装Docker Engine - Community

    • 安装最新版本(last)

      yum install docker-ce docker-ce-cli containerd.io

    • 安装指定版本

      1
      2
      yum list docker-ce --showduplicates | sort -r  #查看版本
      sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io #安装指定版本
  • 启动与测试

    1
    2
    sudo systemctl start docker  # 启动docker
    docker run hello-world #测试

    启动安装成功的页面如下:

  • 使用docker快捷部署web版

    1
    2
    3
    4
    5
    6
    7
    $ docker pull wcjiang/reference

    $ docker run --name reference --rm -d -p 9667:3000 wcjiang/reference:latest
    # Or
    $ docker run --name reference -itd -p 9667:3000 wcjiang/reference:latest

    7ce85ba828134a3b38c67d3c3eae852e6fc83a94cc234f8fd715ade0756f14cc

    部署成功的页面如下: