ChatGPT解决这个技术问题 Extra ChatGPT

即使安装了 apt-get 也找不到 docker 命令

添加此内容以供其他人参考,因为如果存在这样的答案,它将为我节省 10 分钟。

我尝试使用 ubuntu 14.0LTS virtualbox 安装 Docker

sudo apt get install docker

但是,当我尝试运行 docker 时,它给了我以下错误

The program 'docker' is currently not installed. You can install it by typing: sudo apt-get install docker

为什么ubuntu看不到docker?


A
Andrew

Ubuntu 包 docker 实际上是指一个 GUI 应用程序,而不是我们寻找的心爱的 DevOps 工具。

可以按照此处 docker 页面上的说明遵循 docker 的说明:https://docs.docker.com/engine/install/ubuntu/

=== 已更新(感谢@Scott Stensland)===

您现在运行以下安装脚本来获取 docker:

sudo curl -sSL https://get.docker.com/ | sh

注意:查看网站上的脚本并确保您拥有正确的链接,然后再继续,因为您是以 sudo 运行此脚本。

这将运行一个安装 docker 的脚本。注意脚本的最后一部分:

If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker stens

Remember that you will have to log out and back in for this to take effect!

要更新 Docker 运行:

sudo apt-get update && sudo apt-get upgrade

有关正在发生的事情的更多详细信息,请参阅下面的 docker install documentation 或 @Scott Stensland 的回答

.

=== 更新:对于那些使用 sudo 感到不舒服的人 |嘘 ===

评论中的一些人提到将任意脚本作为 sudo 运行是有风险的。上面的选项是一个来自 docker 的便捷脚本,用于简化任务。但是,对于那些注重安全但不想阅读脚本的人,您可以执行以下操作:

添加依赖项

sudo apt-get update; \
sudo apt-get install \
 apt-transport-https \
 ca-certificates \
 curl \
 gnupg-agent \
 software-properties-common

添加 docker gpg 密钥

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

(安全检查,验证密钥指纹9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

$ sudo apt-key fingerprint 0EBFCD88

pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

)

设置存储库

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

安装 Docker

sudo apt-get update; \
sudo apt-get install docker-ce docker-ce-cli containerd.io

如果您想验证它是否正常运行:sudo docker run hello-world

下面解释了它为什么这样命名:Why install docker on ubuntu should be `sudo apt-get install docker.io`?


apt-cache search docker 将向您展示很多东西,其中 docklet KDE 3/GNOME 2 不是您要寻找的,而 Linux container runtime 更好
此答案已过时...请参阅上面的其他答案
被否决是因为正确的简短答案隐藏在底部。
我是唯一一个认为 sudo curl | sh 看起来像个坏主意的人吗?
“不是心爱的 DevOps 工具”——这让我大笑起来
S
Scott Stensland

重要 - ubuntu 包 docker 完全不同(避免使用它):

发出以下问题以查看是否有任何软件包提到 docker

dpkg -l|grep docker

如果只有匹配项,那么您没有安装下面的 docker 是一个不相关的包

docker - KDE3/GNOME2 docker 应用程序的系统托盘

如果您确实看到上面的内容,请删除它,因为它是错误的 docker

sudo apt-get remove docker #删除错误的docker

如果您看到类似于以下内容的内容,那么您已经安装了 docker

 dpkg -l|grep docker

ii  docker-ce                                  5:19.03.13~3-0~ubuntu-focal         amd64        Docker: the open-source application container engine
ii  docker-ce-cli                              5:19.03.13~3-0~ubuntu-focal         amd64        Docker CLI: the open-source application container engine

注意 - ubuntu 包 docker.io 未获得更新(已过时请勿使用)

而是这样做:通过执行以下命令在 linux 上安装最新版本的 docker:

sudo apt-get install docker-ce

下面是另一种发出安装命令的方法

  sudo curl -sSL https://get.docker.com/ | sh
# sudo curl -sSL https://test.docker.com | sh  # get dev pipeline version
  

这是一个典型的输出(ubuntu 16.04)

apparmor is enabled in the kernel and apparmor utils were already installed
+ sudo -E sh -c apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Executing: /tmp/tmp.rAAGu0P85R/gpg.1.sh --keyserver
hkp://ha.pool.sks-keyservers.net:80
--recv-keys
58118E89F3A912897C070ADBF76221572C52609D
gpg: requesting key 2C52609D from hkp server ha.pool.sks-keyservers.net
gpg: key 2C52609D: "Docker Release Tool (releasedocker) <docker@docker.com>" 1 new signature
gpg: Total number processed: 1
gpg:         new signatures: 1
+ break
+ sudo -E sh -c apt-key adv -k 58118E89F3A912897C070ADBF76221572C52609D >/dev/null
+ sudo -E sh -c mkdir -p /etc/apt/sources.list.d
+ dpkg --print-architecture
+ sudo -E sh -c echo deb [arch=amd64] https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list
+ sudo -E sh -c sleep 3; apt-get update; apt-get install -y -q docker-engine
Hit:1 http://repo.steampowered.com/steam precise InRelease
Hit:2 http://download.virtualbox.org/virtualbox/debian xenial InRelease                                                           
Ign:3 http://dl.google.com/linux/chrome/deb stable InRelease                                                                      
Hit:4 http://dl.google.com/linux/chrome/deb stable Release                                                                        
Hit:5 http://archive.canonical.com/ubuntu xenial InRelease                                                                        
Hit:6 http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive xenial InRelease                                                     
Hit:7 http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive xenial-updates InRelease                                             
Hit:8 http://ppa.launchpad.net/me-davidsansome/clementine/ubuntu xenial InRelease                                                 
Ign:9 http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.2 InRelease                                                         
Hit:10 http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive xenial-backports InRelease                                          
Hit:11 http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.2 Release                                                          
Hit:12 http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive xenial-security InRelease                                           
Hit:14 http://ppa.launchpad.net/numix/ppa/ubuntu xenial InRelease                                                                 
Ign:15 http://linux.dropbox.com/ubuntu wily InRelease                                                                             
Ign:16 http://repo.vivaldi.com/stable/deb stable InRelease                                                                        
Hit:17 http://repo.vivaldi.com/stable/deb stable Release                                                                          
Get:18 http://linux.dropbox.com/ubuntu wily Release [6,596 B]            
Get:19 https://apt.dockerproject.org/repo ubuntu-xenial InRelease [20.6 kB]    
Ign:20 http://packages.amplify.nginx.com/ubuntu xenial InRelease                      
Hit:22 http://packages.amplify.nginx.com/ubuntu xenial Release
Hit:23 https://deb.opera.com/opera-beta stable InRelease
Hit:26 https://deb.opera.com/opera-developer stable InRelease
Get:28 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages [1,719 B]
Hit:29 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease
Fetched 28.9 kB in 1s (17.2 kB/s)
Reading package lists... Done
W: http://repo.mongodb.org/apt/debian/dists/wheezy/mongodb-org/3.2/Release.gpg: Signature by key 42F3E95A2C4F08279C4960ADD68FA50FEA312927 uses weak digest algorithm (SHA1)
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  aufs-tools cgroupfs-mount
The following NEW packages will be installed:
  aufs-tools cgroupfs-mount docker-engine
0 upgraded, 3 newly installed, 0 to remove and 17 not upgraded.
Need to get 14.6 MB of archives.
After this operation, 73.7 MB of additional disk space will be used.
Get:1 http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive xenial/universe amd64 aufs-tools amd64 1:3.2+20130722-1.1ubuntu1 [92.9 kB]
Get:2 http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive xenial/universe amd64 cgroupfs-mount all 1.2 [4,970 B]
Get:3 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 docker-engine amd64 1.11.2-0~xenial [14.5 MB]
Fetched 14.6 MB in 7s (2,047 kB/s)
Selecting previously unselected package aufs-tools.
(Reading database ... 427978 files and directories currently installed.)
Preparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1ubuntu1_amd64.deb ...
Unpacking aufs-tools (1:3.2+20130722-1.1ubuntu1) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../cgroupfs-mount_1.2_all.deb ...
Unpacking cgroupfs-mount (1.2) ...
Selecting previously unselected package docker-engine.
Preparing to unpack .../docker-engine_1.11.2-0~xenial_amd64.deb ...
Unpacking docker-engine (1.11.2-0~xenial) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu6) ...
Setting up aufs-tools (1:3.2+20130722-1.1ubuntu1) ...
Setting up cgroupfs-mount (1.2) ...
Setting up docker-engine (1.11.2-0~xenial) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for systemd (229-4ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...
+ sudo -E sh -c docker version
Client:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 22:00:43 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 22:00:43 2016
 OS/Arch:      linux/amd64

If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker stens

Remember that you will have to log out and back in for this to take effect!

这是底层的详细安装说明,如您所见,它与上述技术捆绑在一起......上面的一个衬里给您的效果与以下内容相同:

https://docs.docker.com/engine/installation/linux/ubuntulinux/

安装后,您可以通过发出命令查看安装了哪些 docker 软件包

dpkg -l|grep docker
ii  docker-ce                                  5:19.03.13~3-0~ubuntu-focal         amd64        Docker: the open-source application container engine
ii  docker-ce-cli                              5:19.03.13~3-0~ubuntu-focal         amd64        Docker CLI: the open-source application container engine

现在 Docker 更新将在您发布时安装

sudo apt-get update
sudo apt-get upgrade

看一眼

 ls -latr /etc/apt/sources.list.d/*docker*
-rw-r--r-- 1 root root 202 Jun 23 10:01 /etc/apt/sources.list.d/docker.list.save
-rw-r--r-- 1 root root  71 Jul  4 11:32 /etc/apt/sources.list.d/docker.list


cat /etc/apt/sources.list.d/docker.list

deb [arch=amd64] https://apt.dockerproject.org/repo ubuntu-xenial main

或更一般地说

cd /etc/apt
grep -r docker *
sources.list.d/docker.list:deb [arch=amd64] https://download.docker.com/linux/ubuntu focal test

这个答案帮助我弄清楚我被困了 2 天的an issue。谢谢!
在 Linux Mint docker-ce 不可用: sudo apt-get install docker-ce 正在读取包列表...完成 构建依赖关系树 正在读取状态信息...完成 包 docker-ce 不可用,但被另一个包引用.这可能意味着该软件包丢失、已过时或只能从其他来源获得
C
Chandra Kanth
sudo apt-get install docker # DO NOT do this

是 ubuntu 上的一个不同的库。

使用 sudo apt-get install docker-ce 安装正确的 docker。


为了完整起见:packages.ubuntu.com/artful/docker System tray for KDE3/GNOME2 docklet applications
sudo apt-get install docker-ce 读取包列表...完成构建依赖树读取状态信息...完成包docker-ce不可用,但被另一个包引用。这可能意味着该软件包丢失、已过时或只能从其他来源获得 E: 软件包 'docker-ce' 没有安装候选者`
J
Junius L.

设置存储库

对于 Ubuntu 14.04/16.04/16.10/17.04:

sudo add-apt-repository "deb [arch=amd64] \
     https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

对于 Ubuntu 17.10:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable"

添加 Docker 的官方 GPG 密钥:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

然后安装

$ sudo apt-get update && sudo apt-get -y install docker-ce

N
Nimantha

如果你想以一种简单的方式安装 docker。只需输入:

$sudo apt install docker.io

并且,它将开始安装。并且,要检查其是否正常工作,请键入:

$docker