ubuntu20.04 LTS安裝docker的方法步驟
零:卸載舊版本
Docker 的舊版本被稱為 docker,docker.io 或 docker-engine 。如果已安裝,請卸載它們:
$ sudo apt-get remove docker docker-engine docker.io containerd runc
當前稱為 Docker Engine-Community 軟件包 docker-ce 。
一:設置倉庫
在新主機上首次安裝 Docker Engine-Community 之前,需要設置 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]
使用以下指令設置穩(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運行&鏡像加速
免sudo
參考如下方法將用戶添加到docke組
$ sudo usermod -aG docker [你的用戶名]
重啟docker
$ sudo systemctl restart docker
(然而我的機器上發(fā)生了很詭異的事——我重啟docker服務后依然不能以普通用戶啟動docker。重啟機器后才能免sudo運行。)
docker鏡像加速
我用了阿里云的免費加速
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
后續(xù)設置按照阿里云網(wǎng)頁內(nèi)提示即可,不再贅述。
五:參考鏈接
-Windows10 安裝 WSL2 Ubuntu20.04 并設置 docker 環(huán)境
-Ubuntu Docker 安裝
到此這篇關于ubuntu20.04 LTS安裝docker的方法步驟的文章就介紹到這了,更多相關ubuntu20.04 LTS安裝docker內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Docker安裝MySQL并使用Navicat連接的操作方法
這篇文章主要介紹了Docker安裝MySQL并使用Navicat連接,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-09-09
Docker部署KingbaseES數(shù)據(jù)庫操作指南
本文主要介紹了Docker部署KingbaseES數(shù)據(jù)庫操作指南,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2026-04-04
在Docker中安裝Oracle數(shù)據(jù)庫超詳細步驟
oracle作為全球最強大的關系型數(shù)據(jù)庫,應用在各行各業(yè),下面這篇文章主要給大家介紹了關于在Docker中安裝Oracle數(shù)據(jù)庫的相關資料,文中通過代碼介紹的非常詳細,需要的朋友可以參考下2024-01-01
使用DockerFile構建鏡像與鏡像上傳的實現(xiàn)步驟
本文主要介紹了使用DockerFile構建鏡像與鏡像上傳的實現(xiàn)步驟,使用Dockerfile好處是自動化構建,確保環(huán)境的一致性和可重復性,跟蹤構建過程的演化等,文中通過圖文講解的非常詳細,需要的朋友可以參考下2024-02-02

