安装 docker 环境 for CentOS

安装 docker

  • 删除老版本

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    $ 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
  • 配置 repo

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    $ 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

    # Optional
    $ sudo yum-config-manager --enable docker-ce-edge
    $ sudo yum-config-manager --enable docker-ce-test
    $ sudo yum-config-manager --disable docker-ce-edge
  • 安装 docker

    1
    $ sudo yum install docker-ce
    • 安装指定版本 docker

      1
      2
      3
      4
      5
      # List and sort the versions available in your repo
      # 可以查看所有仓库中所有docker版本,并选择特定版本安装
      $ yum list docker-ce --showduplicates | sort -r
      docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
      $ sudo yum install docker-ce-<VERSION STRING>
  • 启动并加入开机启动

    1
    2
    3
    4
    5
    6
    7
    8
    # 启动 docker
    $ sudo systemctl start docker
    # 停止运行 docker
    $ sudo systemctl stop docker
    # 开机启动
    $ sudo systemctl enable docker
    # 禁止开机启动
    $ sudo systemctl disable docker
  • 验证安装

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    $ docker version
    Client:
    Version: 18.06.1-ce
    API version: 1.38
    Go version: go1.10.3
    Git commit: e68fc7a
    Built: Tue Aug 21 17:23:03 2018
    OS/Arch: linux/amd64
    Experimental: false

    Server:
    Engine:
    Version: 18.06.1-ce
    API version: 1.38 (minimum version 1.12)
    Go version: go1.10.3
    Git commit: e68fc7a
    Built: Tue Aug 21 17:25:29 2018
    OS/Arch: linux/amd64
    Experimental: false
  • 本文作者: forever杨
  • 本文链接: https://blog.yl-online.top/posts/2fff8f5e.html
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。如果文章内容对你有用,请记录到你的笔记中。本博客站点随时会停止服务,请不要收藏、转载!