如何在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. 

我正在关注的教程

在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的更多详细信息。

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

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

xenial替换xenial 。 运行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 

自动安装

如果您希望“自动”完成所有安装步骤,您还可以使用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 - 

validation密钥指纹是否为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)  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 curl -fsSL https://get.docker.com/ | sh .. .. .. sudo usermod -aG docker $USER来源: https : //github.com/moby/moby/releases/tag/v17.05.0-ce

在Ubuntu 17.04上,官方回购的deb安装工作得很好(17.05)

https://github.com/moby/moby/releases/tag/v17.05.0-ce

 #!/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)  # 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