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

mev*_*sme 5 apt docker

我按照指南中所述执行所有操作,但我得到
\n我使用的指南: https: //docs.docker.com/desktop/install/ubuntu/

\n
user@pc:~/Downloads$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin\nReading package lists... Done\nBuilding dependency tree... Done\nReading state information... Done\nPackage docker-ce is not available, but is referred to by another package.\nThis may mean that the package is missing, has been obsoleted, or\nis only available from another source\n\nPackage docker-ce-cli is not available, but is referred to by another package.\nThis may mean that the package is missing, has been obsoleted, or\nis only available from another source\n\nE: Package \'docker-ce\' has no installation candidate\nE: Package \'docker-ce-cli\' has no installation candidate\nE: Unable to locate package containerd.io\nE: Couldn\'t find any package by glob \'containerd.io\'\nE: Couldn\'t find any package by regex \'containerd.io\'\nE: Unable to locate package docker-compose-plugin\n
Run Code Online (Sandbox Code Playgroud)\n

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

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

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

\n
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\n\n\nuser@pc:~/Downloads$  sudo apt update\nHit:1 http://ua.archive.ubuntu.com/ubuntu jammy InRelease\nHit:2 http://ua.archive.ubuntu.com/ubuntu jammy-updates InRelease              \nHit:3 http://ua.archive.ubuntu.com/ubuntu jammy-backports InRelease            \nGet:4 https://download.docker.com/linux/ubuntu jammy InRelease [48,9 kB]       \nGet:5 http://dl.google.com/linux/chrome/deb stable InRelease [1\xe2\x80\xaf811 B]         \nGet:6 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]      \nIgn:7 https://ppa.launchpadcontent.net/rock-core/qt4/ubuntu jammy InRelease    \nHit:8 https://repo.skype.com/deb stable InRelease                              \nGet:9 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages [6\xe2\x80\xaf255 B]\nErr:5 http://dl.google.com/linux/chrome/deb stable InRelease                   \n  The following signatures couldn\'t be verified because the public key is not available: NO_PUBKEY 4EB27DB2A3B88B8B\nErr:10 https://ppa.launchpadcontent.net/rock-core/qt4/ubuntu jammy Release     \n  404  Not Found [IP: 185.125.190.52 443]\nIgn:11 http://linux.dropbox.com/ubuntu disco InRelease                         \nGet:12 http://linux.dropbox.com/ubuntu disco Release [6\xe2\x80\xaf598 B]\nGet:13 http://security.ubuntu.com/ubuntu jammy-security/main amd64 DEP-11 Metadata [11,4 kB]\nGet:14 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 DEP-11 Metadata [10,1 kB]\nGet:15 http://linux.dropbox.com/ubuntu disco Release.gpg [473 B]    \nGet:16 http://linux.dropbox.com/ubuntu disco/main amd64 Packages [1\xe2\x80\xaf169 B]\nGet:17 http://linux.dropbox.com/ubuntu disco/main i386 Packages [1\xe2\x80\xaf163 B]\nReading package lists... Done             \nW: 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\nE: The repository \'http://dl.google.com/linux/chrome/deb stable InRelease\' is not signed.\nN: Updating from such a repository can\'t be done securely, and is therefore disabled by default.\nN: See apt-secure(8) manpage for repository creation and user configuration details.\nE: The repository \'https://ppa.launchpadcontent.net/rock-core/qt4/ubuntu jammy Release\' does not have a Release file.\nN: Updating from such a repository can\'t be done securely, and is therefore disabled by default.\nN: See apt-secure(8) manpage for repository creation and user configuration details.\nW: 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.\nW: 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.\n\n\nuser@pc:~/Downloads$  sudo apt install docker-ce\nReading package lists... Done\nBuilding dependency tree... Done\nReading state information... Done\nYou might want to run \'apt --fix-broken install\' to correct these.\nThe following packages have unmet dependencies:\n docker-ce : Depends: containerd.io (>= 1.4.1) but it is not going to be installed\n             Depends: docker-ce-cli but it is not going to be installed\n             Recommends: docker-ce-rootless-extras but it is not going to be installed\n             Recommends: pigz but it is not going to be installed\n docker-desktop : Depends: qemu-system-x86 (>= 5.2.0) but it is not going to be installed\n                  Depends: docker-ce-cli but it is not going to be installed\n                  Depends: pass but it is not going to be installed\n                  Depends: uidmap\nE: Unmet dependencies. Try \'apt --fix-broken install\' with no packages (or specify a solution).\n
Run Code Online (Sandbox Code Playgroud)\n

我该怎么办请帮忙!

\n

小智 8

这个问题由 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
Run Code Online (Sandbox Code Playgroud)

此命令下载最新版本的 Docker Compose(从 Compose 版本存储库)并在$HOME目录下为活动用户安装 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
Run Code Online (Sandbox Code Playgroud)

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

 sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
Run Code Online (Sandbox Code Playgroud)

测试安装。

 docker compose version
Run Code Online (Sandbox Code Playgroud)