安装Docker
容器。
Install Docker CE
Install using the repository
Set up the repository
- Update the
apt
package index:
1 |
$ sudo apt-get update |
- Install packages to allow
apt
to use a repository over HTTPS:
1 |
$ sudo apt-get install \ |
- 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 |
$ sudo apt-key fingerprint 0EBFCD88 |
- 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 word
edge
ortest
(or both) after the wordstable
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 |
$ sudo add-apt-repository \ |
armhf
1 |
$ echo "deb [arch=armhf] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \ |
Install Docker CE
- Update the
apt
package index.
1 |
$ sudo apt-get update |
- 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 |
- 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 |
$ apt-cache madison docker-ce |
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.
- 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.