Docker 安装

安装Docker容器。

Install Docker CE

Install using the repository

Set up the repository

  1. Update the apt package index:
1
$ sudo apt-get update
  1. Install packages to allow apt to use a repository over HTTPS:
1
2
3
4
5
6
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
  1. Add Docker’s official GPG key:
1
$ curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -

Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

1
2
3
4
5
6
$ 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
  1. Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well. To add the edge or test repository, add the wordedge or test (or both) after the word stable in the commands below.

To also add the edge repository, add edge after stable on the last line of the command.

x86_64 / amd64

1
2
3
4
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable"

armhf

1
2
3
$ echo "deb [arch=armhf] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list

Install Docker CE

  1. Update the apt package index.
1
$ sudo apt-get update
  1. Install the latest version of Docker CE, or go to the next step to install a specific version. Any existing installation of Docker is replaced.
1
$ sudo apt-get install docker-ce
  1. On production systems, you should install a specific version of Docker CE instead of always using the latest. This output is truncated. List the available versions:
1
2
3
$ apt-cache madison docker-ce

docker-ce | 17.09.0~ce-0~debian | https://download.docker.com/linux/debian jessie/stable amd64 Packages

The contents of the list depend upon which repositories are enabled. Choose a specific version to install. The second column is the version string. The third column is the repository name, which indicates which repository the package is from and by extension its stability level. To install a specific version, append the version string to the package name and separate them by an equals sign (=):

1
$ sudo apt-get install docker-ce=<VERSION_STRING>

The Docker daemon starts automatically.

  1. Verify that Docker CE is installed correctly by running the hello-world image.

x86_64:

1
$ sudo docker run hello-world

armhf:

1
$ sudo docker run armhf/hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

0%