English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Ubuntu Docker Installation

Docker Engine-Community supports the following Ubuntu versions:

  • Xenial 16.04 (LTS)

  • Bionic 18.04 (LTS)

  • Cosmic 18.10

  • Disco 19.04

  • Other updated versions...

Docker Engine - Community support on x86_64(or amd64)armhf, arm64, s390x (IBM Z), and ppc64le (IBM's Power) architecture.

Install automatically using the official installation script

The installation command is as follows:

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

You can also use the one-click installation command of domestic daocloud:

curl -sSL https://get.daocloud.io/docker | sh

Manual installation

Uninstall old versions

The old version of Docker is called docker, docker.io, or docker-engine. If they are already installed, please uninstall them:

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

Currently known as Docker Engine-Community software package docker-ce .

Install Docker Engine-Community, the following introduces two methods.

Install using Docker repository

First install Docker Engine on a new host-Before setting up the Docker repository, you need to set up the Docker repository. After that, you can install and update Docker from the repository.

Set up the repository

Update the apt package index.

$ sudo apt-get update

Install apt dependency packages for retrieving the repository via HTTPS:

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

Add Docker's official GPG key:

$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 By searching for the fingerprint at the end8characters, verify that you currently have a key with the fingerprint.

$ sudo apt-key fingerprint 0EBFCD88
    
pub rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <[email protected]>
sub rsa4096 2017-02-22 [S]

Use the following command to set up the stable repository

$ sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
   $(lsb_release -cs) \
   stable"

Install Docker Engine-Community

Update the apt package index.

$ sudo apt-get update

Install the latest version of Docker Engine-Community and containerd, or proceed to the next step to install a specific version:

$ sudo apt-get install docker-ce docker-ce-cli containerd.io

要安装特定版本的 Docker Engine-Community,请在仓库中列出可用版本,然后选择一种安装。列出您的仓库中可用的版本:

$ apt-cache madison docker-ce
  docker-ce | 5:18.09.1~3-0~ubuntu-xenial | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  docker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  docker-ce | 18.06.1~ce~3-0~ubuntu       | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  docker-ce | 18.06.0~ce~3-0~ubuntu       | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  ...

使用第二列中的版本字符串安装特定版本,例如 5:18.09.1~3-0~ubuntu-xenial。

$ sudo apt-get install docker-ce= docker-ce-cli= containerd.io

测试 Docker 是否安装成功,输入以下指令,打印出以下信息则安装成功:

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete                                                                                                                                  Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
状态:已下载新的 hello 镜像-world:latest
您好,来自 Docker!
此消息显示您的安装似乎正在正常工作。
为了生成此消息,Docker 执行了以下步骤:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/
For more examples and ideas, visit:
 https://docs.docker.com/get-started/

install using Shell scripts

Docker in get.docker.com and test.docker.com convenient scripts for quickly installing Docker Engine-Community's edge versions and test versions. The source code of the script is provided on docker-in the install repository. It is not recommended to use these scripts in a production environment, and you should understand the potential risks before using them:

  • The script needs to be run as root or with sudo privileges. Therefore, you should carefully check and review the script before running it.

  • These scripts attempt to detect Linux distributions and versions, and configure the package management system for you. In addition, the script does not allow you to customize any installation parameters. From the perspective of Docker or your own organized guidelines and standards, this may lead to unsupported configurations.

  • These scripts will install all dependencies and recommended software packages of the package manager without confirmation. This may install a large number of packages, depending on the current configuration of the host.

  • This script does not provide an option to specify which version of Docker to install; instead, it installs the latest version released in the edge channel.

  • If Docker has already been installed on the host using another mechanism, do not use the convenient script.

This example uses get.docker.com script to install the latest version of Docker Engine on Linux-Community. To install the latest test version, please use test.docker.com. In the following commands, replace each occurrence of get with test.

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh

If you want to use Docker as a non-root user, you should consider adding the user to the docker group in a way similar to the following:

$ sudo usermod -aG docker your-user