建立 REPOSITORY
1.更新索引包
更新 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的地址,這樣才能獲取到最新的軟件包
sudo apt-get update
2.獲取HTTPS支持
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
3.添加docker公共秘鑰(官方地址)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
驗證此apt-key是否安裝成功
sudo apt-key fingerprint 0EBFCD88
4.設置版本類型,docker版本包括:stable、edge、test(每季度更新stable版本,每個月更新edge版本)。
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
修改的文件在:/etc/apt/sources.list
終端執行時可以看到Ubuntu18.04對應版本為bionic
安裝 DOCKER CE
1.更新索引包
sudo apt-get update
2.安裝最新版Docker CE
sudo apt-get install docker-ce
或者安裝制定版本的Docker CE,生產環境安裝docker要指定版本安裝,不要安裝最新版本。
apt-cache madison docker-ce
3.設置開機自啟動並啟動 Docker-ce(安裝成功后默認已設置並啟動,可忽略)
sudo systemctl enable docker sudo systemctl start docker
卸載
1.卸載docker ce
sudo apt-get purge docker-ce
2.刪除鏡像、容器、卷
sudo rm -rf /var/lib/docker
參考文獻:https://docs.docker.com/install/linux/docker-ce/ubuntu/#upgrade-docker-ce