如何在 Ubutntu 22.04 上安装 docker 和 docker-compose?

如何在 Ubutntu 22.04 上安装 docker 和 docker-compose?

我按照指南中所说的做了所有事情,但我得到了
我使用的指南:https://docs.docker.com/desktop/install/ubuntu/

user@pc:~/Downloads$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package docker-ce is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package docker-ce-cli is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'docker-ce' has no installation candidate
E: Package 'docker-ce-cli' has no installation candidate
E: Unable to locate package containerd.io
E: Couldn't find any package by glob 'containerd.io'
E: Couldn't find any package by regex 'containerd.io'
E: Unable to locate package docker-compose-plugin

当我尝试安装依赖项时出现这些错误

user@pc:~/Downloads$  sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ca-certificates is already the newest version (20211016).
lsb-release is already the newest version (11.1.0ubuntu4).
software-properties-common is already the newest version (0.99.22.3).
software-properties-common set to manually installed.
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 docker-desktop : Depends: qemu-system-x86 (>= 5.2.0) but it is not going to be installed
                  Depends: docker-ce-cli but it is not installable
                  Depends: pass but it is not going to be installed
                  Depends: uidmap
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

当我安装docker时我得到了这个:

user@pc:~/Downloads$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null


user@pc:~/Downloads$  sudo apt update
Hit:1 http://ua.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://ua.archive.ubuntu.com/ubuntu jammy-updates InRelease              
Hit:3 http://ua.archive.ubuntu.com/ubuntu jammy-backports InRelease            
Get:4 https://download.docker.com/linux/ubuntu jammy InRelease [48,9 kB]       
Get:5 http://dl.google.com/linux/chrome/deb stable InRelease [1 811 B]         
Get:6 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]      
Ign:7 https://ppa.launchpadcontent.net/rock-core/qt4/ubuntu jammy InRelease    
Hit:8 https://repo.skype.com/deb stable InRelease                              
Get:9 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages [6 255 B]
Err:5 http://dl.google.com/linux/chrome/deb stable InRelease                   
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4EB27DB2A3B88B8B
Err:10 https://ppa.launchpadcontent.net/rock-core/qt4/ubuntu jammy Release     
  404  Not Found [IP: 185.125.190.52 443]
Ign:11 http://linux.dropbox.com/ubuntu disco InRelease                         
Get:12 http://linux.dropbox.com/ubuntu disco Release [6 598 B]
Get:13 http://security.ubuntu.com/ubuntu jammy-security/main amd64 DEP-11 Metadata [11,4 kB]
Get:14 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 DEP-11 Metadata [10,1 kB]
Get:15 http://linux.dropbox.com/ubuntu disco Release.gpg [473 B]    
Get:16 http://linux.dropbox.com/ubuntu disco/main amd64 Packages [1 169 B]
Get:17 http://linux.dropbox.com/ubuntu disco/main i386 Packages [1 163 B]
Reading package lists... Done             
W: GPG error: http://dl.google.com/linux/chrome/deb stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4EB27DB2A3B88B8B
E: The repository 'http://dl.google.com/linux/chrome/deb stable InRelease' is not signed.
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.
E: The repository 'https://ppa.launchpadcontent.net/rock-core/qt4/ubuntu jammy 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.
W: https://repo.skype.com/deb/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://linux.dropbox.com/ubuntu/dists/disco/Release.gpg: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.


user@pc:~/Downloads$  sudo apt install docker-ce
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 docker-ce : Depends: containerd.io (>= 1.4.1) but it is not going to be installed
             Depends: docker-ce-cli but it is not going to be installed
             Recommends: docker-ce-rootless-extras but it is not going to be installed
             Recommends: pigz but it is not going to be installed
 docker-desktop : Depends: qemu-system-x86 (>= 5.2.0) but it is not going to be installed
                  Depends: docker-ce-cli but it is not going to be installed
                  Depends: pass but it is not going to be installed
                  Depends: uidmap
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

我该怎么办,请帮帮忙!

答案1

这个问题可以通过docker自己检查来回答 您可以手动安装插件

要下载并安装 Compose CLI 插件,请运行:

 DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
 mkdir -p $DOCKER_CONFIG/cli-plugins
 curl -SL https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose

$HOME此命令下载 Docker Compose 的最新版本(来自 Compose 发布存储库)并为目录下的活动用户安装 Compose 。

安装:

对于系统上的所有用户,将 Docker Compose 替换~/.docker/cli-plugins/usr/local/lib/docker/cli-plugins。对于其他版本的 Compose,将 v2.12.2 替换为要使用的 Compose 版本。将可执行权限应用于二进制文件:

 chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose

或者,如果你选择为所有用户安装 Compose:

 sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose

测试安装。

 docker compose version

答案2

你可以试试:

sudo pip3 install docker-compose

它对我有帮助

相关内容