添加 yum

yum install epel-release –y
yum clean all
yum list

移除舊版,安裝新版本

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 info

安裝必要的 repository

sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

使用 stable repository

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

啟用 edge (可自行決定是否啟用)

sudo yum-config-manager --enable docker-ce-edge

(若不想啟用 edge,也可以直接關閉):

sudo yum-config-manager --disable docker-ce-edge

安裝新版本

sudo yum install docker-ce

檢查安裝結果

docker info

啟動/關閉

sudo systemctl start docker     #運行Docker守護進程
sudo systemctl stop docker      #停止Docker守護進程
sudo systemctl restart docker   #重啟Docker守護進程

安裝 Docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

添加權限

sudo chmod +x /usr/local/bin/docker-compose

檢查 docker-compose 是否安裝完畢

docker-compose --version