如何在Ubuntu 17.04上安装Docker


32

我已经安装了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.

我正在关注的教程


从2017年中开始,docker-ce 17.06可用于Ubuntu 17.04(已于2017年6月发布,因此版本为17.06)-请按照此处的步骤操作:docs.docker.com/engine/installation/linux/docker-ce / Ubuntu的 (以及从得到搬运工-撰写pip(例如,sudo -H pip3 install docker-compose)和 从ubuntu的回购,这是外的日期。
迈克尔

Answers:


8

在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。您将需要先手动启动dockerd该页面包含有关如何从二进制文件安装和运行docker的更多详细信息。


1
您也可以只使用xenial存储库,请参阅我的答案
bluehallu

请注意,get.docker.com软件包已过时,并且.tgz归档文件包含静态链接的二进制文件,而这可能不是您想要的。Docker现在具有可用于Ubuntu zesty的软件包;请参阅docs.docker.com/engine/installation/linux/docker-ce/ubuntu。但是,get.docker.com上的安装脚本仍是最新的,因此运行该脚本将安装正确的软件包
thaJeztah

60

Docker尚未为最新的ubuntu设置存储库,但这很容易解决,因为它们的ubuntu 16版本是兼容的。目前,只需进行编辑/etc/apt/sources.list并在线:

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

替换zestyxenial。运行sudo apt-get update,您可以继续sudo apt-get install docker-ce


4
如果您像我一样直接添加此代码,则需要此存储库的PGP密钥apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7EA0A9C3F273FCD8
timelf123

@bluehallu:看到了您的编辑,但我无法将其与今天的存储库配合使用。apt-get说没有docker-ce的安装候选
Thiago Arrais

@ThiagoArrais删除了编辑,测试时我可能做错了
bluehallu

如果您添加@ timelf123中提到的密钥服务器,则效果很好
SMMousavi

这个答案现在已经过时了,但是它对我不起作用,可能是由于版本不匹配(尤其是docker-compose)。但这是一个有争议的问题,因为docker.com(不是 ubuntu存储库)具有适用于Ubuntu 17.04的docker -ce版本17.06。(这些版本有点令人困惑:2017年6月发布的docker-ce是v17.06)。如果从docker.com安装docker-ce,则必须从docker-compose的git版本或通过sudo -H pip install docker-compose而不是ubuntu repos 来安装docker-compose ,这些东西现在对docker相关的东西无用(截至2017年中) 。
迈克尔(Michael)

17

简要说明一下:当前要在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 -ce指令终于被更新为有用的文档。docker.com/engine/installation/linux/docker -ce/ ubuntu 一个人应该以stable两种方式添加存储库,并edge在必要时添加(稳定表现在包括针对ubuntu的发行版) 17.04 zesty)
迈克尔(Michael

14

该线程中的信息已过时,可能会导致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

自动安装

如果要“自动”完成所有安装步骤,还可以使用位于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
好的,我已经更新了帖子,以包含安装过程的完整详细信息。
达到峰值


1
使用17.10为我工作,而docs.docker.com/engine/installation/linux/docker-ce/ubuntu没有使用
Vadorequest

4

我终于设法使它起作用。这是适合我的解决方案:

  1. 使用Ravexina提出的解决方案:

    sudo apt install docker.io

  2. 然后使用这个:

    sudo gpasswd -a ${USER} docker

  3. 最后,重新启动系统

Voilà……效果很好。


4
这将从标准Ubuntu存储库中安装相当旧的版本(当前为1.12.6-0ubuntu4)。如果您使用@ Georgi-Goranov的解决方案,则将获得最新版本(当前为17.05.0〜ce-0〜ubuntu-zesty)。
Christopher K.

3
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

这将安装
docker

它为我工作
jijeesh



0
#!/bin/bash
# file: src/bash/aspark-starter/install-docker-on-ubuntu-17.04.sh
# Purpose: 
# to automate the installation of docker-ce on Ubuntu 17.04 zesty
# 
# courtesy of https://askubuntu.com/a/944174/251228
set -eu -o pipefail # fail on error , debug all lines

# run as root
[ "$USER" = "root" ] || exec sudo "$0" "$@"

echo "=== $BASH_SOURCE on $(hostname -f) at $(date)" >&2

err_msg="\n\nthis script is only for Ubuntu 17.04 zesty, BUT you have: \n"$(lsb_release -a)
test $(lsb_release -cs) != "zesty" && echo -e "$err_msg"
test $(lsb_release -cs) != "zesty" && exit 1

echo Install Using the Repository
echo Update the apt package index:


apt-get update

echo Install packages to allow apt to use a repository over HTTPS:

apt-get install -y \
     apt-transport-https \
     ca-certificates \
     curl \
     software-properties-common


echo Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -


echo Verify that the key fingerprint is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.
apt-key fingerprint 0EBFCD88

echo << EOF_STDOUT
# the output should look like : 
# 
# 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

EOF_STDOUT


echo Use the following command to set up the stable repository for the amd64 architecture
# src: https://unix.stackexchange.com/a/181538/37428
# tested only for amd64
arch=$(dpkg --print-architecture)
add-apt-repository \
    "deb [arch=""$arch""] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) \
    stable"

echo INSTALL DOCKER CE
sudo apt-get update
sudo apt-get install -y docker-ce

echo the docker binary is installed in
which docker

echo DONE !!!
# eof file src/bash/aspark-starter/install-docker-on-ubuntu-17.04.sh
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.