fbpx

I suggest you get machine to follow along this part. So here’s a little plug of our own: Cloud VPS, for as little as €2.95 a month.

This article is a part of our complete series of articles on Docker. Click here to access the Free Series.

While Docker was initially only used on Linux distributions, the current version of the container engine is largely platform- independent. Installation packages are available for Microsoft Windows and macOS as well as for cloud services such as Amazon Web Services (AWS) and Microsoft Azure. Supported Linux distributions include:

  • CentOS
  • Debian
  • Fedora
  • Oracle Linux
  • Red Hat Enterprise Linux
  • Ubuntu
  • openSUSE
  • SUSE Linux Enterprise

There are also Docker distributions maintained by communities for:

  • Arch Linux
  • CRUX Linux
  • Gentoo Linux

In the following, we illustrate the installation process of the Docker engine using the example of the popular Linux distribution Ubuntu . You   can find detailed installation instructions for the other platforms in the English-language Docker documentation.

Depending on the requirements and prerequisites to be met, you have three different options for installing the Docker container platform on your Ubuntu system:

  • Manual installation via DEB package
  • Installation from the Docker repository
  • Installation from the Ubuntu repository

Before doing this, however, you should take a look at the system requirements for the Docker engine.

System requirements

To install the current version of Docker on your Ubuntu distribution, you need the 64-bit version of one of the following Ubuntu versions:

  • Yakkety 16.10
  • Xenial 16.04 (LTS)
  • Trusty 14.04 (LTS)

Before the Docker installation

The following tutorial is based on the Ubuntu version Xenial 16.04 (LTS) . For Yakkety 16.10, the installation process follows the same steps. Users of Trusty 14.04 (LTS) are recommended to install the linux-image-extra- * packages before installing Docker . These enable the Docker engine to access the AUFS storage drivers.

The integrated APT package manager offers a convenient method of providing a Linux system with updates(Advanced Packaging Tool) . To install the additional packages for Trusty 14.04 , perform the following steps:

1. Call up the terminal: Start Ubuntu and open the terminal – for example using the key combination [CTRL] + [ALT] + [T].

The terminal under Ubuntu Xenial 16.04 (LTS)
To perform actions in the terminal as administrator, precede program calls with the command sudo.

2. Update package lists: Enter the following command to update the local package index of your operating system. Confirm your entry with the [ENTER] key.

$ sudo apt-get update

The addition sudo enables you to execute commands as administrator (superuser “root”). Certain commands may require root privileges to run. In this case, Ubuntu will prompt you for the administrator password. Alternatively, you have the option of permanently changing to the administrator role via sudo -s . tip

To install the Docker container platform, you need root rights for the respective host system.

Password query in the Ubuntu terminal
Note: If you enter a password in the Ubuntu Terminal, you will not see any wildcard characters

If you have identified yourself as the root user with a password, Ubuntu starts the update process. The status is displayed in the terminal.

Package management in the Ubuntu terminal via APT
The command Ubuntu sudo apt-get update brings the list of available packages up to date

3. Install additional packages: If all package descriptions have been updated, you can proceed to the installation of new packages. The APT package manager provides the apt-get install “PackageName” command for this purpose. To load the recommended additional packages for Trusty 14.04 from the Ubuntu repository and install them on your system, enter the following command in the terminal and confirm with [ENTER].

$ sudo apt-get install -y --no-install-recommends \
    linux-image-extra-$(uname -r) \
    linux-image-extra-virtual
Package installation via the Ubuntu terminal
Before installing new packages, it is recommended that you update the local package lists

After the additional packages forTrusty 14.04 have been downloaded, all functions of the Docker platform are also available on this Ubuntu version.

Not sure what version of Ubuntu your system is? Or are you not sure whether you can provide the 64-bit architecture required for a Docker installation? Kernel version and system architecture can be determined in the Ubuntu terminal using the following command:

$ sudo uname -rm 

The respective Ubuntu version , the release and the nickname can be displayed by entering the following:

$ sudo lsb_release –a
Get Ubuntu system information through the terminal
System information can also be called up conveniently via the terminal under Ubuntu

Manual installation via DEB package

In principle, Docker can be downloaded as a DEB package and installed manually . The required installation package is available at the following URL:

https://apt.dockerproject.org/repo/pool/main/d/docker-engine/

Download the DEB file of the desired Ubuntu version and start the installation process with this command from the Ubuntu terminal:

$ sudo dpkg -i /path/to/package.deb 

In the case of manual installation, all software updates must also be done manually . The Docker documentation therefore recommends using Docker’s own repository. This makes it possible to conveniently install the container platform from the Ubuntu terminal and keep it up to date.

Below we illustrate the Docker installation according to the recommended practice.

Installation from the Docker repository

The recommended way to create your own container platform is to install it from the Docker repository. We will show you how to configure your system so that the APT package manager can access the Docker repository via HTTPS .

1.Install packages: Enter the following command to install the packages required to access the Docker repository:

$ sudo apt-get install -y --no-install-recommends \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
Installation of the configuration packages via the Ubuntu terminal
Follow the installation process for the output in the terminal

2. Add GPG Key: Add Docker’s official GPG key.

$ curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add -
Adding the GPG key via apt-key add
If the selected key was successfully added, Ubuntu returns an “OK” in the terminal

3. verify GPG key: Make sure that the GPG key with the following ID matches: 5811 8E89 F3A9 1289 7C07 0ADB F762 2157 2C52 609D . Use the following command for this:

$ apt-key fingerprint 58118E89F3A912897C070ADBF76221572C52609D

The output appears in the terminal:

pub   4096R/2C52609D 2015-07-14
        Key fingerprint = 5811 8E89 F3A9 1289 7C07  0ADB F762 2157 2C52 609D
uid                  Docker Release Tool (releasedocker) <docker@docker.com>
Verification of the GPG key
Match the output in the terminal with the GPG key from Docker

4. Configure the Docker repository: Enter the following command to ensure access to the stable Docker repository:

$ sudo add-apt-repository \
       "deb https://apt.dockerproject.org/repo/ \
       ubuntu-$(lsb_release -cs) \
       main"
Configuration of the Docker repository
Configure access to the stable Docker repository

Your system is now completely preconfigured for the installation of the container platform from the Docker repository. tip

As an alternative to the stable repository, you can also use Docker’s test repository. To do this, call up the /etc/apt/sources.list file and replace the word main with testing . We do not recommend using the test repository on production systems.

5. Update package index: Before you continue with the installation of the Docker engine, it is advisable to update the package index of your operating system again. To do this, use the command again:

$ sudo apt-get update

6. Docker installation from the repository: You have two options to load the Docker engine from the Docker repository and install it on your Ubuntu system.If you want to load the latest version of the Docker engine, use the command:

$ sudo apt-get -y install docker-engine
Docker installation processes: status display in the terminal
Follow the progress of the installation process via the terminal

The container platform is ready for use as soon as the installation process is complete.

The Docker daemon starts automatically. If there was an older version of the container platform on your system before the Docker installation, it was replaced by the newly installed software.

As an alternative to the latest version, any older version of the Docker engine can be installed. This is useful, for example, when used on productive systems. Here, users sometimes prefer established releases with good experience to newer software versions.

You can get an overview of the Docker versions available for your system with the following command:

$ apt-cache madison docker-engine
Version overview of the Docker engine in the terminal
Select the desired Docker release from the list of available software versions

To install a special Docker version, simply add the respective version string to the installation command (e.g. 1.12.5-0 ) by adding an equal sign to the package name (in this case docker-engine ) append.

$ sudo apt-get -y install docker-engine=<VERSION_STRING>

Installation from the Ubuntu repository

Users who do not want to use the Docker repository also have the option of loading the container platform from the operating system’s own repository .

Use the following command line command to install a Docker package provided by the Ubuntu community :

$ sudo apt-get install -y docker.io

 tip

The installation package of the container platform “docker.io” should not be confused with the package “docker”, a system tray for KDE3 / GNOME2 docklet applications.

Test run

After you have successfully completed the installation process, you should make sure that the container platform is working properly. The development team provides a simple hello-world container for this. Check your Docker installation by entering the following command in the Ubuntu terminal and confirming with [ENTER]:

$ sudo docker run hello-world 

 Danger

The Docker daemon is tied to a Unix socket (i.e. to a communication endpoint provided by the operating system) that is assigned to the root user in the standard setting. Other users can therefore only use Docker commands with the addition of sudo . This can be changed by creating a Unix group called docker and adding the users you want . You can find more information on this in the documentation for the Docker project .

The docker run command instructs the Docker daemon to find and start a container named hello-world . If your Docker installation is configured correctly, you should get output that corresponds to the screenshot below.

Terminal output of the hello-world container
The greeting “Hello from Docker” shows you that your Docker installation is working properly

This terminal output can be interpreted as follows: To execute the command docker run hello-world , the Docker daemon first searches the local files of your system for the corresponding container image. Since this is the first time you are running the hello-world container , the daemon’s search will be unsuccessful. You will receive the message “Unable to find image”(“The image could not be found”).

$ sudo docker run hello-world
[sudo] password for osboxes:
Unable to find image 'hello-world:latest' locally

If Docker cannot find a desired image on the local system, the daemon initiates a download process (pulling) from the Docker repository.

latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest

After a successful download, you get the message: “Downloaded newer image for hello-world: latest ” ( “New Image for hello-world: latest downloaded”). Then the container is started . This contains a simple hello-world script with the following message from the developers:

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.
 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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

For you this text means: Your Docker installation works perfectly .

Uninstall Docker

Just as easily as installing the Docker engine via the terminal, the container platform can also be uninstalled in this way . If you want to remove the Docker package from your system, enter the following command in the Ubuntu terminal and confirm with [ENTER]:

 $ sudo apt-get purge docker-engine

After the information required for the uninstallation has been read in, you will be asked to confirm the command again.

Docker deinstallation via the terminal
Uninstall the Docker platform using the apt-get purge command

To continue, enter “Y” (Yes) and confirm with [ENTER]. Select “n” to cancel the uninstallation.

Images and containers are not automatically removed when the Docker engine is uninstalled . Delete them using this command:

$ sudo rm -rf /var/lib/docker

If additional configuration files were installed, these must be removed manually.


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: