一、rmp安裝
安裝包下載地址:
https://download.docker.com/linux/centos/
~]#? ?wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm
~]#? ?yum -y install docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm
二、yum源安裝
1、配置yum源
~]#??mkdir /etc/yum.repos.d/back
~]#??mv /etc/yum.repos.d/* /etc/yum.repos.d/back/
~]#??wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
~]#??wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
~]#??wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo?
2、執(zhí)行安裝
~]#???yum -y install docker-ce? ? ? #默認(rèn)安裝最新版本的
~]#? ? yum list docker-ce --showduplicates | sort -r? ? ? ?#查看倉庫中的所有docker版本
~]#? ??yum -y install docker-ce-19.03.1 docker-ce-cli-19.03.1? ? ?#指定安裝版本
3、啟動并驗(yàn)證docker版本
~]#? ?systemctl start docker
~]#? ?systemctl enable?docker? ? ? #加入開機(jī)自啟動
~]#? ?docker version?
三、Ubuntu安裝docker
1、如已安裝久版本,通過如下命令進(jìn)行卸載
:~#? ?apt-get remove docker docker-engine docker.io containerd runc
2、更新apt包索引
:~#? ?apt-get??update
3、允許apt通過HTTPS來獲取倉庫
:~#??apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
4、添加 Docker 的官方 GPG 密鑰
:~#??curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add
5、驗(yàn)證當(dāng)前機(jī)器現(xiàn)在是否擁有帶有指紋的密鑰
:~#??apt-key fingerprint 0EBFCD88

6、設(shè)置穩(wěn)定版?zhèn)}庫
:~#? add-apt-repository \
? ?> "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
? ?> $(lsb_release -cs) \
? ?> stable"
7、過濾可安裝的的docker版本
:~#? ?apt-cache madison docker-ce
8、安裝docker,默認(rèn)安裝最新版本
:~#? ?apt-get??update
:~#??apt-get install docker-ce docker-ce-cli containerd.io
9、指定安裝版本:
apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
:~#???apt-get install docker-ce=5:19.03.0~3-0~ubuntu-bionic?docker-ce-cli=5:19.03.0~3-0~ubuntu-bionic?containerd.io??
10、啟動并驗(yàn)證docker版本
:~#???systemctl start docker
:~#???docker version
:~#???systemctl enable docker? ?#設(shè)置開機(jī)自啟動

