ubuntu20.04 LTS安裝docker的方法步驟
零:卸載舊版本
Docker 的舊版本被稱為 docker,docker.io 或 docker-engine 。如果已安裝,請卸載它們:
$ 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個字符,驗證您現(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 源,暫時用 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
三:測試
輸入
$ 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ù)后依然不能以普通用戶啟動docker。重啟機(jī)器后才能免sudo運(yùn)行。)
docker鏡像加速
我用了阿里云的免費加速
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)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。