ubuntu安裝docker(測試:ubuntu 18.4)

簡介:

ubuntu安裝很簡單,就直接放操作了。

附加:快速搭建各種漏洞環境(Various vulnerability environment) https://github.com/Medicean/VulApps
ubuntu16.4或18.4前期的源和系統準備可以參照:https://blog.csdn.net/lm2017/article/details/101985812

操作:


1.刪除原先的docker(默認沒有)
 sudo apt-get remove docker docker-engine docker.io containerd runc

2.添加 Docker 的官方 GPG 密鑰
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -


3.驗證您現在是否擁有帶有指紋的密鑰
sudo apt-key fingerprint 0EBFCD88


4.設置穩定版倉庫
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"


5. 安裝最新的Docker-ce 
 sudo apt-get update
sudo apt-get install docker-ce


6.apt-get install docker-ce可能會出現的問題,無問題直接跳過
可能會發生下面的提示:
    無法獲得鎖 /var/lib/dpkg/lock - open (11: 資源暫時不可用)
    無法鎖定管理目錄(/var/lib/dpkg/),是否有其他進程正佔用它?
解決辦法如下:
(1)終端輸入 ps  aux ,列出進程。找到含有apt-get的進程,直接sudo kill PID。(應該會kill把)
(2)強制解鎖,命令
    sudo rm /var/cache/apt/archives/lock
    sudo rm /var/lib/dpkg/lock
完成後重新 sudo apt-get install docker-ce

7.配置docker鏡像加速
sudo curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://d1c9c786.m.daocloud.io
sudo systemctl restart docke



問題附加:

1.用Hello World校驗Docker的安裝

sudo docker run hello-world

如果出現Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world
d1725b59e92d: Pull complete 

不要慌,服務器從Docker Hub獲取到最新的Hello World鏡像,下載到本地。

再次輸入docker run hello-world,回車:

Hello from Docker.
This message shows that your installation appears to be working correctly.

2.Error response from daemon: Get https://registry-1.docker.io/v2/: x509: certificate is valid for drivefca.com, www.drivefca.com, not registry-1.docker.io(20200403更新問題)

或者提示

 sudo vim /etc/docker/daemon.json(若沒有自行創建)
寫入:
{
  "registry-mirrors": [
    "http://hub-mirror.c.163.com"
  ],
  "insecure-registries": [
    "registry-1.docker.io"
  ]
}

最終重啓一下docker:
sudo systemctl daemon-reload 
sudo systemctl restart docker

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章