零:卸載舊版本
Docker 的舊版本被稱為 docker,docker.io 或 docker-engine 。如果已安裝,請(qǐng)卸載它們:
$ sudo apt-get remove docker docker-engine docker.io containerd runc
當(dāng)前稱為 Docker Engine-Community 軟件包 docker-ce 。
一:設(shè)置倉庫
在新主機(jī)上首次安裝 Docker Engine-Community 之前,需要設(shè)置 Docker 倉庫。之后,您可以從倉庫安裝和更新 Docker 。
更新 apt 包索引。
$ sudo apt-get update
安裝 apt 依賴包,用于通過HTTPS來獲取倉庫:
$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
添加 Docker 的官方 GPG 密鑰:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 通過搜索指紋的后8個(gè)字符,驗(yàn)證您現(xiàn)在是否擁有帶有指紋的密鑰。
$ sudo apt-key fingerprint 0EBFCD88 pub rsa4096 2017-02-22 [SCEA] 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid [ unknown] Docker Release (CE deb) <docker@docker.com> sub rsa4096 2017-02-22 [S]
使用以下指令設(shè)置穩(wěn)定版?zhèn)}庫
注意:目前 20.04 還沒有國內(nèi) docker 源,暫時(shí)用 18.04 版本。
$ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ bionic \ stable"
二:安裝 Docker Engine-Community
更新 apt 包索引。
$ sudo apt-get update
安裝最新版本的 Docker Engine-Community 和 containerd
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
三:測(cè)試
輸入
$ sudo docker run hello-world
如果docker和你問好——或者說出現(xiàn)類似以下輸出
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
就說明安裝完事了。
四:免sudo運(yùn)行&鏡像加速
免sudo
參考如下方法將用戶添加到docke組
$ sudo usermod -aG docker [你的用戶名]
重啟docker
$ sudo systemctl restart docker
(然而我的機(jī)器上發(fā)生了很詭異的事——我重啟docker服務(wù)后依然不能以普通用戶啟動(dòng)docker。重啟機(jī)器后才能免sudo運(yùn)行。)
docker鏡像加速
我用了阿里云的免費(fèi)加速
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
后續(xù)設(shè)置按照阿里云網(wǎng)頁內(nèi)提示即可,不再贅述。
五:參考鏈接
-Windows10 安裝 WSL2 Ubuntu20.04 并設(shè)置 docker 環(huán)境
-Ubuntu Docker 安裝
到此這篇關(guān)于ubuntu20.04 LTS安裝docker的方法步驟的文章就介紹到這了,更多相關(guān)ubuntu20.04 LTS安裝docker內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
標(biāo)簽:棗莊 鹽城 96 渭南 日照 東莞 常州 克拉瑪依
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ubuntu20.04 LTS安裝docker的方法步驟》,本文關(guān)鍵詞 ubuntu20.04,LTS,安裝,docker,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。