Starting in March 2017, Docker began to be divided into Community versions and Enterprise Editions, Docker CE and Docker EE, and the way it was installed was obsolete in the original Ubuntu14.04 sudo apt-get install docker.io
. Here, we will detail how to install the Docker Community Edition under ubuntu14.04 Lts, the Docker CE.
Before you start, make sure you do some pre-prep work before you start installing Docker.
Pre-preparation operating system
To install Docker CE, you need one of the following 64-bit Ubuntu operating systems:
- Artful 17.10 (Docker CE 17.11 Edge only)
- Zesty 17.04
- $Xenial $16.04 (LTS)
- Trusty 14.04 (LTS)
The Docker CE is allowed to be installed on x86_64
, armhf
as well as s390x
(IBM Z Systems) architecture on top of the Ubuntu operating system.
Cleanup of outdated Docker versions
Older versions of Docker are usually called docker
or docker-engine
, if they were previously installed in the operating system, please uninstall it first:
$ sudo apt-get remove docker docker-engine docker.io
Use to see if there are any apt-get
related packages, and if not, the cleanup succeeds.
Installing the Docker CE
The Docker CE has several different installation modes:
- It is recommended that most users install the Docker repository (Docker's repositories) and then be installed by the repository, which is easy to install and easy to upgrade.
- Some users can manually install and manually upgrade by downloading the Debian package. This practice can be useful in some cases, such as installing Docker CE in an offline environment.
- In some development or test environments, some users have the option of installing the Docker CE with an automated script.
Installation via repositories
Before you install the Docker CE on a new machine for the first time, you need to set up Docker repositories first. You can then install or upgrade Docker from the repositories.
Set repositories
apt
index information for the upgrade source:
$ sudo apt-get update
- Installs the specified packages that allow
apt
access to repository over https:
$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
- Add the official GPG key provided by Docker:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
By using the apt-key finger print
last 8 digits of the search fingerprint code, you can verify that the fingerprint code you generated in the previous step should be9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
$ sudo apt-key fingerprint 0EBFCD88pub 4096R/0EBFCD88 2017-02-22 Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88uid Docker Release (CE deb) <[email protected]>sub 4096R/F273FCD8 2017-02-22
- Use the following command to set up a stable repository, the following command is based on the x86_64 platform only, if you want to use a different platform installation, please refer to the official documentation:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Installing the Docker CE
apt
index information for the upgrade source:
$ sudo apt-get update
- Install the latest version of Docker CE, or skip this step and specify the installed version in the third step:
sudo apt-get install docker-ce
When there are multiple Docker repository libraries?
When there are multiple Docker repository available on your machine. If apt-get install
apt-get update
You do not specify the installed Docker version when you use or command the installation or update operation, you will always install the highest version of Docker that is supported in these repository, and be aware that this is the version you really need. If not, specify the version at the time of installation.
- In a real-world product environment system, you may need to install the specified version of Docker CE instead of always installing the default version. Use the following command to list the relevant version information that is allowed to be used:
$ apt-cache madison docker-cedocker-ce | 17.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
The content listed in the command return result depends on the repository present in the system, and you can select the specified version number from the returned results to install the Docker CE. The second column is the version information. The third column is the name of repository, which identifies the installation package from that repository and the stability of the current version. If you want to install the specified version, add the version number to the back of the package name (where the package name is Docker-ce), separated by ( =
):
$ sudo apt-get install docker-ce=<VERSION>
After the installation is complete, the Docker daemon (Docker server daemon) will automatically start running.
- Run an
hello-world
image to verify that the installation is correct:
$ sudo docker run hello-world
Run this command to automatically download a test image and run it in a container. After it is run, a message is printed and then exited automatically.
Hello from Docker!This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps: 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
When the Docker CE installation is complete, the docker
group is created automatically, but no user is in the default. So you still need to use it sudo
to start and run the Docker command. Linux Postinstall can be configured to allow non-authorized users to run and configure Docker CE.
Upgrade Docker CE
If you need to upgrade the Docker CE, run it first, then install the sudo apt-get update
new Docker CE version by installing the installation steps described above and re-selecting it.
The way to install the Docker CE via repository is here to end, and the next article will continue to introduce the installation of the Docker CE through the package and the script.
Installing the Docker CE (1)-Repository under Ubuntu14.04