十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
本篇內(nèi)容介紹了“ubuntu怎么安裝docker”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!
創(chuàng)新互聯(lián)建站是一家專業(yè)從事網(wǎng)站建設(shè)、網(wǎng)站制作的網(wǎng)絡(luò)公司。作為專業(yè)網(wǎng)站建設(shè)公司,創(chuàng)新互聯(lián)建站依托的技術(shù)實力、以及多年的網(wǎng)站運營經(jīng)驗,為您提供專業(yè)的成都網(wǎng)站建設(shè)、營銷型網(wǎng)站建設(shè)及網(wǎng)站設(shè)計開發(fā)服務(wù)!
零:卸載舊版本
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è)置倉庫
在新主機上首次安裝 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)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運行&鏡像加速
免sudo
參考如下方法將用戶添加到docke組
$ sudo usermod -ag docker [你的用戶名]
重啟docker
$ sudo systemctl restart docker
(然而我的機器上發(fā)生了很詭異的事——我重啟docker服務(wù)后依然不能以普通用戶啟動docker。重啟機器后才能免sudo運行。)
docker鏡像加速
我用了阿里云的免費加速
“ubuntu怎么安裝docker”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!