1. 程式人生 > 其它 >阿里雲部署docker

阿里雲部署docker

Ubuntu18.04

# step 1: 安裝必要的一些系統工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安裝GPG證書
curl -fsSLhttp://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg| sudo apt-key add -
# Step 3: 寫入軟體源資訊
sudo add-apt-repository "deb [arch=amd64]http://mirrors.aliyun.com/docker-ce/linux/ubuntu

$(lsb_release -cs) stable"
# Step 4: 更新並安裝 Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce

# 安裝指定版本的Docker-CE:
# Step 1: 查詢Docker-CE的版本:
# apt-cache madison docker-ce
# docker-ce | 17.03.1~ce-0~ubuntu-xenial |http://mirrors.aliyun.com/docker-ce/linux/ubuntuxenial/stable amd64 Packages
# docker-ce | 17.03.0~ce-0~ubuntu-xenial |
http://mirrors.aliyun.com/docker-ce/linux/ubuntu
xenial/stable amd64 Packages
# Step 2: 安裝指定版本的Docker-CE: (VERSION 例如上面的 17.03.1~ce-0~ubuntu-xenial)
# sudo apt-get -y install docker-ce=[VERSION]

centos7安裝

1、解除安裝舊版本,docker舊版本被稱為docker or docker-engine 如果已安裝這些,需要先解除安裝因為其中是有依賴項的

sudoyum remove docker \ docker-client \
docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine


如果yum報告裡報告了沒有安裝這些軟體包 則可以進行安裝
2、安裝依賴包:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

2.1、新增docker軟體安裝包源:
sudo yum-config-manager --add-repohttps://download.docker.com/linux/centos/docker-ce.repo


2.1.1、可以使用阿里雲的映象地址,pull映象速度更快
sudo yum-config-manager --add-repohttp://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

2.2、更新yum包索引:
sudo yum makecache fast

sudo yum list docker-ce --showduplicates | sort -r

docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
如果安裝指定版本

yum install docker-ce-17.12.0.ce-1.el7.centos


2.3、安裝docker CE
sudo yum install -y docker-ce
2.4、啟動docker服務
sudo systemctl start docker
2.5、docker服務自啟動
sudo systemctl enable docker