有關docker,我在Linux虛擬機上安裝的是Ubuntu18.04.2版本,這個過程問題並不大,但是后續通過終端安裝docker時,遇到了不少問題
安裝docker需要在終端完成以下幾個命令的輸入(更准確的可以參考docker官方文檔 https://docs.docker.com/install/linux/docker-ce/ubuntu/ )
(1)sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
(2)curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
(3)sudo add-apt-respository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
(4)sudo apt-get update
sudo apt-get install docker-ce
總的來說有以下三個錯誤
1. 大概意思為 “無法獲取資源的錯誤” ,當時忘記截圖了,好像是進行到第三步時遇到的,搜索百度眾“神人”的解決方法,其中主要有兩種
(1)殺掉apt-get進程
ps aux | grep apt-get (會顯示進程的信息)
sudo kill 進程PID
(2)強制解鎖
sudo rm /var/cache/apt/archives/lock
sudo rm /var.lib/dpkg/lock
我先嘗試了第一種方法,但是並不管用,后來用來第二種方法,解決了問題
2. apt-get update 出現了 NO_PUBKEY的錯誤,百度時發現這一錯誤出現的關鍵參數也有所不同,我的錯誤如下
W: GPG error: https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8
解決方法:添加公匙
sudo apt-key adv --recv-keys --keyserver keyserver.ubutun.com 7EA0A9C3F273FCD8
3.一個低級錯誤,創建端口映射容器時,顯示沒有權限的錯誤,因為是普通用戶而非root用戶,沒有在命令前加sudo,
在原本的命令前加上 sudo 即可。