当前位置: 首页>>技术教程>>正文


如何在Ubuntu 17.04上安装Docker

, ,

问题描述

我安装了Ubuntu 17.04(VirtualBox)。但是因为我有Ubuntu 17.04,看起来Docker还没有用于Ubuntu 17.04。在Ubuntu 17.04上安装Docker有什么解决方法吗?

这是我的命令行历史:

 2  curl -L https://github.com/docker/machine/releases/download/v0.10.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&   chmod +x /tmp/docker-machine &&   sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
 3  docker-machine version
 4  docker pull ubuntu:latest
 5  sudo apt-get update
 6  sudo apt-get install     linux-image-extra-$(uname -r)     linux-image-extra-virtual
 7  sudo apt-get install     apt-transport-https     ca-certificates     curl     software-properties-common
 8  sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 9  sudo apt-key fingerprint 0EBFCD88
10  lsb_release -cs
11  sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
12  sudo apt-get update
13  sudo apt-get install docker-ce -y

这是实际错误:

user@user-vm:~$ sudo apt-get update

Hit:1 http://ch.archive.ubuntu.com/ubuntu zesty InRelease
Hit:2 http://ch.archive.ubuntu.com/ubuntu zesty-updates InRelease       
Get:3 http://security.ubuntu.com/ubuntu zesty-security InRelease [89.2 kB]
Hit:4 http://ch.archive.ubuntu.com/ubuntu zesty-backports InRelease                 
Ign:5 https://download.docker.com/linux/ubuntu zesty InRelease                      
Ign:6 https://download.docker.com/linux/ubuntu zesty Release
Ign:7 https://download.docker.com/linux/ubuntu zesty/stable all Packages
Ign:8 https://download.docker.com/linux/ubuntu zesty/stable amd64 Packages
Ign:9 https://download.docker.com/linux/ubuntu zesty/stable Translation-en_US
Ign:10 https://download.docker.com/linux/ubuntu zesty/stable Translation-en
Ign:11 https://download.docker.com/linux/ubuntu zesty/stable all DEP-11 Metadata
Ign:12 https://download.docker.com/linux/ubuntu zesty/stable amd64 DEP-11 Metadata
Ign:13 https://download.docker.com/linux/ubuntu zesty/stable DEP-11 64x64 Icons
Ign:7 https://download.docker.com/linux/ubuntu zesty/stable all Packages
Ign:8 https://download.docker.com/linux/ubuntu zesty/stable amd64 Packages
Ign:9 https://download.docker.com/linux/ubuntu zesty/stable Translation-en_US
Ign:10 https://download.docker.com/linux/ubuntu zesty/stable Translation-en
Ign:11 https://download.docker.com/linux/ubuntu zesty/stable all DEP-11 Metadata
Ign:12 https://download.docker.com/linux/ubuntu zesty/stable amd64 DEP-11 Metadata
Ign:13 https://download.docker.com/linux/ubuntu zesty/stable DEP-11 64x64 Icons
Ign:7 https://download.docker.com/linux/ubuntu zesty/stable all Packages
Ign:8 https://download.docker.com/linux/ubuntu zesty/stable amd64 Packages
Ign:9 https://download.docker.com/linux/ubuntu zesty/stable Translation-en_US
Ign:10 https://download.docker.com/linux/ubuntu zesty/stable Translation-en
Ign:11 https://download.docker.com/linux/ubuntu zesty/stable all DEP-11 Metadata
Ign:12 https://download.docker.com/linux/ubuntu zesty/stable amd64 DEP-11 Metadata                                                                                                                   
Ign:13 https://download.docker.com/linux/ubuntu zesty/stable DEP-11 64x64 Icons                                                                                                                      
Ign:7 https://download.docker.com/linux/ubuntu zesty/stable all Packages                                                                                                                             
Ign:8 https://download.docker.com/linux/ubuntu zesty/stable amd64 Packages                                                                                                                           
Ign:9 https://download.docker.com/linux/ubuntu zesty/stable Translation-en_US                                                                                                                        
Ign:10 https://download.docker.com/linux/ubuntu zesty/stable Translation-en                                                                                                                          
Ign:11 https://download.docker.com/linux/ubuntu zesty/stable all DEP-11 Metadata                                                                                                                     
Ign:12 https://download.docker.com/linux/ubuntu zesty/stable amd64 DEP-11 Metadata                                                                                                                   
Ign:13 https://download.docker.com/linux/ubuntu zesty/stable DEP-11 64x64 Icons                                                                                                                      
Ign:7 https://download.docker.com/linux/ubuntu zesty/stable all Packages                                                                                                                             
Ign:8 https://download.docker.com/linux/ubuntu zesty/stable amd64 Packages                                                                                                                           
Ign:9 https://download.docker.com/linux/ubuntu zesty/stable Translation-en_US                                                                                                                        
Ign:10 https://download.docker.com/linux/ubuntu zesty/stable Translation-en                                                                                                                          
Ign:11 https://download.docker.com/linux/ubuntu zesty/stable all DEP-11 Metadata                                                                                                                     
Ign:12 https://download.docker.com/linux/ubuntu zesty/stable amd64 DEP-11 Metadata                                                                                                                   
Ign:13 https://download.docker.com/linux/ubuntu zesty/stable DEP-11 64x64 Icons                                                                                                                      
Ign:7 https://download.docker.com/linux/ubuntu zesty/stable all Packages                                                                                                                             
Err:8 https://download.docker.com/linux/ubuntu zesty/stable amd64 Packages                                                                                                                           
404  Not Found
Ign:9 https://download.docker.com/linux/ubuntu zesty/stable Translation-en_US                                                                                                                        
Ign:10 https://download.docker.com/linux/ubuntu zesty/stable Translation-en                                                                                                                          
Ign:11 https://download.docker.com/linux/ubuntu zesty/stable all DEP-11 Metadata                                                                                                                     
Ign:12 https://download.docker.com/linux/ubuntu zesty/stable amd64 DEP-11 Metadata                                                                                                                   
Ign:13 https://download.docker.com/linux/ubuntu zesty/stable DEP-11 64x64 Icons                                                                                                                      
Fetched 89.2 kB in 12s (7'258 B/s)                                                                                                                                                                   
Reading package lists... Done
W: The repository 'https://download.docker.com/linux/ubuntu zesty Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch https://download.docker.com/linux/ubuntu/dists/zesty/stable/binary-amd64/Packages  404  Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.

tutorial I was following

最佳解决办法

在Ubuntu 17.04中还没有对docker的官方支持。另一种方法是从https://github.com/moby/moby/releases下载并安装docker的二进制文件。

例如,如果要从二进制文件安装docker版本17.04.0-ce,请按照下列步骤操作:

$ wget https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz
$ tar xzvf docker-17.04.0-ce.tgz
$ cd docker

docker目录包含所有二进制文件。您需要将此目录添加到PATH。您需要先手动启动dockerdThis page包含有关如何从二进制文件安装和运行docker的更多详细信息。

次佳解决办法

Docker还没有为最新的ubuntu设置存储库,但这是一个简单的解决方案,因为它们的ubuntu 16版本是兼容的。目前,只需编辑/etc/apt/sources.list并在线:

deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable

xenial代替zesty。运行sudo apt-get update,您可以继续使用sudo apt-get install docker-ce

第三种解决办法

快速说明:目前要在ubuntu 17.04(zesty)上安装docker-ce,您需要处于边通道:请参阅https://github.com/moby/moby/issues/32423#issuecomment-300164496

因此,您需要将deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty edge添加到您的来源。

第四种办法

这个信息已经过时,可能导致docker安装失灵;现在支持ubuntu zesty,并提供软件包;请参阅安装手册:https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/

卸载旧版本

较旧版本的Docker称为dockerdocker-engine。如果已安装,请卸载它们:

$ sudo apt-get remove docker docker-engine docker.io

自动安装

如果要完成所有安装步骤”automatically”,还可以使用https://get.docker.com/的安装脚本

使用存储库安装

更新apt包索引:

$ sudo apt-get update

安装包以允许通过HTTPS使用存储库:

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    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   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22

使用以下命令设置稳定存储库(对于amd64体系结构):

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

安装DOCKER CE

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

谢谢Sebastiaan van Stijn帮我解决这个问题。

第五种办法

我终于成功了。这是适用于我的解决方案:

  1. 使用Ravexina提出的解决方案:sudo apt install docker.io

  2. 然后使用它:sudo gpasswd -a ${USER} docker

  3. 最后,重新启动我的系统

Voilà……它很完美。

第六种办法

sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D  
sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-zesty testing'    
apt-get update    
apt-cache policy docker-engine    
apt-get install docker-engine

第七种办法

只需使用以下
curl -fsSL https://get.docker.com/ | sh
..
..
..
sudo usermod -aG docker $USER
来源:https://github.com/moby/moby/releases/tag/v17.05.0-ce

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/2506.html,未经允许,请勿转载。