2023年8月21日 星期一

Linux Mint在升級後,Docker就無法安裝的解決方法

【前言】

前幾天,我把VM上的Linux Mint從21.1升級到了21.2,然後再來安裝Docker時,Docker就一直出錯,再也裝不起來了。後來解決了,解決方法如下。

【解決過程】

 先來看看情況是怎樣?

cheeren@cheeren-virtual-machine:~$ sudo apt-get update

[sudo] cheeren 的密碼:         

已有:1 http://free.nchc.org.tw/ubuntu jammy InRelease

已有:2 http://free.nchc.org.tw/ubuntu jammy-updates InRelease                  

已有:3 http://free.nchc.org.tw/ubuntu jammy-backports InRelease                

已有:4 https://dl.google.com/linux/chrome/deb stable InRelease                 

略過:5 http://ftp.tku.edu.tw/Linux/LinuxMint/linuxmint victoria InRelease      

已有:6 http://ftp.tku.edu.tw/Linux/LinuxMint/linuxmint victoria Release        

已有:7 http://packages.microsoft.com/repos/code stable InRelease               

已有:8 https://packages.microsoft.com/repos/edge stable InRelease              

已有:9 http://security.ubuntu.com/ubuntu jammy-security InRelease              

正在讀取套件清單... 完成

cheeren@cheeren-virtual-machine:~$ sudo apt-get install \

    ca-certificates \

    curl \

    gnupg \

    lsb-release

正在讀取套件清單... 完成

正在重建相依關係... 完成  

正在讀取狀態資料... 完成  

lsb-release 已是最新版本 (11.1.0ubuntu4)。

ca-certificates 已是最新版本 (20230311ubuntu0.22.04.1)。

curl 已是最新版本 (7.81.0-1ubuntu1.13)。

gnupg 已是最新版本 (2.2.27-3ubuntu2.1)。

升級 0 個,新安裝 0 個,移除 0 個,有 2 個未被升級。

cheeren@cheeren-virtual-machine:~$ sudo mkdir -p /etc/apt/keyrings

cheeren@cheeren-virtual-machine:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

檔案 '/etc/apt/keyrings/docker.gpg' 已存在. 是否覆寫?(y/N) y

cheeren@cheeren-virtual-machine:~$ echo \

  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \

  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

cheeren@cheeren-virtual-machine:~$ sudo apt-get update

已有:1 http://free.nchc.org.tw/ubuntu jammy InRelease

已有:2 http://free.nchc.org.tw/ubuntu jammy-updates InRelease                  

已有:3 http://free.nchc.org.tw/ubuntu jammy-backports InRelease                

已有:4 https://dl.google.com/linux/chrome/deb stable InRelease                 

已有:5 http://packages.microsoft.com/repos/code stable InRelease               

略過:6 http://ftp.tku.edu.tw/Linux/LinuxMint/linuxmint victoria InRelease      

已有:7 http://ftp.tku.edu.tw/Linux/LinuxMint/linuxmint victoria Release        

已有:8 https://packages.microsoft.com/repos/edge stable InRelease

已有:9 http://security.ubuntu.com/ubuntu jammy-security InRelease

略過:10 https://download.docker.com/linux/ubuntu victoria InRelease

錯誤:11 https://download.docker.com/linux/ubuntu victoria Release

  404  Not Found [IP: 13.35.35.17 443]

正在讀取套件清單... 完成

E: The repository 'https://download.docker.com/linux/ubuntu victoria Release' does not have a Release file.

N: Updating from such a repository can't be done securely, and is therefore disabled by default.

N: See apt-secure(8) manpage for repository creation and user configuration details.


這裡出錯了,所以不能更新。不解決這個問題的話是無法繼續安裝的。

先來看看最重要的檔案出了什麼問題?先看看repository哪裡不對。


cheeren@cheeren-virtual-machine:~$ cat /etc/apt/sources.list.d/docker.list 

deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu   victoria stable


沒錯,問題就出在這裡。由於我目前所在的OS的是Linux Mint,而不是Ubuntu。


這裡要說明要如何修改/etc/apt/sources.list.d/docker.list:

首先,看看版本出了什麼問題:


cheeren@cheeren-virtual-machine:~$ cat /etc/os-release | grep -i codename

VERSION_CODENAME=victoria

UBUNTU_CODENAME=jammy


原來是CODENAME的問題!

Linux Mint的CODENAME目前是victoria,而若是對照Ubuntu,Ubuntu目前版本的CODENAME則是jammy。我現在Docker所使用的安裝套件是Ubuntu所用的套件,所以,要把/etc/apt/sources.list.d/docker.list中,所有victoria改成jammy即可。

這裡要注意權限,因為這個檔案只能有ROOT權限才能修改。修改完後請繼續:


cheeren@cheeren-virtual-machine:~$ sudo vi /etc/apt/sources.list.d/docker.list


修改好了之後,重來一次:


cheeren@cheeren-virtual-machine:~$ sudo apt-get update

略過:1 http://ftp.tku.edu.tw/Linux/LinuxMint/linuxmint victoria InRelease

已有:2 http://free.nchc.org.tw/ubuntu jammy InRelease                          

已有:3 https://dl.google.com/linux/chrome/deb stable InRelease                 

已有:4 http://ftp.tku.edu.tw/Linux/LinuxMint/linuxmint victoria Release        

已有:5 http://free.nchc.org.tw/ubuntu jammy-updates InRelease                  

已有:6 http://free.nchc.org.tw/ubuntu jammy-backports InRelease                

下載:7 https://download.docker.com/linux/ubuntu jammy InRelease [48.9 kB]      

已有:8 http://packages.microsoft.com/repos/code stable InRelease               

已有:9 https://packages.microsoft.com/repos/edge stable InRelease              

已有:10 http://security.ubuntu.com/ubuntu jammy-security InRelease  

下載:12 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages [21.4 kB]

取得 70.3 kB 用了 2s (36.8 kB/s)    

正在讀取套件清單... 完成

cheeren@cheeren-virtual-machine:~$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

正在讀取套件清單... 完成

正在重建相依關係... 完成  

正在讀取狀態資料... 完成  

下列的額外套件將被安裝:

  docker-buildx-plugin docker-ce-rootless-extras git git-man liberror-perl

  libslirp0 pigz slirp4netns

建議套件:

  aufs-tools cgroupfs-mount | cgroup-lite git-daemon-run | git-daemon-sysvinit

  git-doc git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn

下列【新】套件將會被安裝:

  containerd.io docker-buildx-plugin docker-ce docker-ce-cli

  docker-ce-rootless-extras docker-compose-plugin git git-man liberror-perl

  libslirp0 pigz slirp4netns

升級 0 個,新安裝 12 個,移除 0 個,有 2 個未被升級。

需要下載 118 MB 的套件檔。

此操作完成之後,會多佔用 435 MB 的磁碟空間。

是否繼續進行 [Y/n]? [Y/n] 


以下略過......


設定 git (1:2.34.1-1ubuntu1.10) ...

執行 man-db (2.10.2-1) 的觸發程式……

執行 libc-bin (2.35-0ubuntu3.1) 的觸發程式……


看看是否安裝成功?


cheeren@cheeren-virtual-machine:~$ docker --version

Docker version 24.0.5, build ced0996


cheeren@cheeren-virtual-machine:~$ sudo docker version

Client: Docker Engine - Community

 Version:           24.0.5

 API version:       1.43

 Go version:        go1.20.6

 Git commit:        ced0996

 Built:             Fri Jul 21 20:35:18 2023

 OS/Arch:           linux/amd64

 Context:           default


Server: Docker Engine - Community

 Engine:

  Version:          24.0.5

  API version:      1.43 (minimum version 1.12)

  Go version:       go1.20.6

  Git commit:       a61e2b4

  Built:            Fri Jul 21 20:35:18 2023

  OS/Arch:          linux/amd64

  Experimental:     false

 containerd:

  Version:          1.6.22

  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca

 runc:

  Version:          1.1.8

  GitCommit:        v1.1.8-0-g82f18fe

 docker-init:

  Version:          0.19.0

  GitCommit:        de40ad0

cheeren@cheeren-virtual-machine:~$ 


成功了!

沒有留言:

張貼留言

用 Claude 在 PsotgreSQL 的 Docker Container 中建立一個 database

Claude 是一個很強的 AI 工具,大概是我用過唯一可以和 Gemini 挑戰的 AI 工具。 它對於程式設計的能力相當強大。我這個測試證明了,不止程式設計能力很強,連資料庫的整個架構能力也是很嚇人的。 之前,我不是在 Proxmox VE 上建了一個 Zorin OS 的 ...