Docker Update Linux



This blog post is the result of collaboration between Arm and Docker. Special thanks to Jason Andrews @ Arm for creating much of the original content.

Arm and Docker announced a strategic partnership earlier this year to unify software development and deployment across a diverse set of devices, from IoT endpoints to the edge of the network, and into the heart of the data center. Docker has simplified enterprise software development and deployment leading to true multi-platform portability and cost savings on Arm-based cloud instances. Even more exciting is how Docker is changing the way embedded software is being developed and deployed.

Install Compose on Linux systems. On Linux, you can download the Docker Compose binary from the Compose repository release page on GitHub.Follow the instructions from the link, which involve running the curl command in your terminal to download the binaries. Docker may periodically prompt you for more information. The Resources tab allows you to configure CPU, memory, disk, proxies, network, and other resources. Different settings are available for configuration depending on whether you are using Linux containers in WSL 2 mode, Linux containers in Hyper-V mode, or Windows containers.

Traditionally embedded Linux software applications have been created by cross-compiling and copying files to an embedded target board. There are various methods to automate this process, but it has generally been unchanged since the 1990’s when non-x86 embedded possessors running Linux appeared. Docker stands to make the first significant change to the embedded Linux application developer’s workflow.

Let’s see how to use Docker for Arm software development using the new buildx feature on Linux to create multi-architecture container images and run them. I’m using Ubuntu 18.04, but the same info applies to most any Linux distribution. Installing Docker on Linux takes just a few commands.

This article continues from Building Multi-Arch Images for Arm and x86 with Docker Desktop and shows the same capabilities in Linux. Although Windows and Mac support is great, the majority of software developers targeting embedded Linux systems also do their development work on Linux. The multi-architecture support in Docker also greatly simplifies embedded Linux application development and deployment.

If you are doing software development on x86 Linux machines and want to create Docker images that run on Arm servers or Arm embedded and IoT devices, this article will be helpful to understand the process and the different ways to do it.

Let’s see how to use Docker for Arm software development using the new buildx feature on Linux to create multi-architecture container images and run them. I’m using Ubuntu 18.04, but the same info applies to most any Linux distribution.

Install Docker

Installing Docker on Linux takes just a few commands. More installation info is available in the Docker Documentation.

If you already have an older version of Docker, make sure to uninstall it first. Using buildx requires Docker 19.03 and today the best way to get this is using the test instead of the stable version.

Add the current user to the docker group to avoid needing sudo to run the docker command:

Make sure to log out and back in again. Now test the install with a quick hello-world run.

Use the docker version command to check the running version:

Install buildx for multi-architecture image builds

There are three options to get buildx on Linux:

  • Use buildx directly from the test channel version of Docker
  • Download a binary release of buildx and copy it to the $HOME/.docker directory
  • Download, build, and install buildx from github.com
Use buildx from Docker test channel

The test version of Docker already has buildx included. The only thing needed is to set the environment variable to enable experimental command line features.

Download a binary release

Another way to get buildx is to download a binary release from github and put in the .docker/cli-plugins directory.

For example, download the buildx for Linux amd64 with a browser from: https://github.com/docker/buildx/releases/tag/v0.2.0

Then copy it to the cli-plugins/ directory (create it first if necessary):

Download, build, and install buildx

Because buildx is a new command and documentation is still catching up, githubis a good place to read more information about how buildx works.

To get buildx from github use the commands:

To confirm buildx is now installed run the help and the version command.

Register Arm executables to run on x64 machines

Install the qemu instruction emulation to register Arm executables to run on the x86 machine. For best results, the latest qemu image should be used. If an older qemu is used some application may not work correctly on the x86 hardware.

To verify the qemu handlers are registered properly, run the following and make sure the first line of the output is “enabled”. Note that the handler registration doesn’t survive a reboot, but could be added to the system start-up scripts.

Create a multi-architecture build instance

Setup a new builder instance to create multi-architecture images.

Try buildx

There are multiple examples of buildx available, but here is a simple one for C programmers! Create a file named hello.c with this code:

Here is a Docker file to build and run it. Let’s get used to using multi-stage Docker files as it will be common for deploying embedded applications. Create a Dockerfile with the following:

Now, use buildx to build for multiple architectures and push to Docker hub.

Use docker login first if needed and substitute your own Hub account.

Run using the sha from the manifest and see the output from uname as armv7l, aarch64, and x86_64:

Next steps

As we have seen, building multi-architecture containers can be created with buildx in the same way as with Docker Desktop for Mac and Windows. Give it a try for yourself and start making the transition to multi-architecture Docker images today.

Further Reading

  • Docker Tutorial
  • Docker Useful Resources
  • Selected Reading

To start the installation of Docker, we are going to use an Ubuntu instance. You can use Oracle Virtual Box to setup a virtual Linux instance, in case you don’t have it already.

The following screenshot shows a simple Ubuntu server which has been installed on Oracle Virtual Box. There is an OS user named demo which has been defined on the system having entire root access to the sever.

To install Docker, we need to follow the steps given below.

Step 1 − Before installing Docker, you first have to ensure that you have the right Linux kernel version running. Docker is only designed to run on Linux kernel version 3.8 and higher. We can do this by running the following command.

uname

This method returns the system information about the Linux system.

Docker Update Linux Operating System

Syntax

Options

a − This is used to ensure that the system information is returned.

Return Value

This method returns the following information on the Linux system −

  • kernel name
  • node name
  • kernel release
  • kernel version
  • machine
  • processor
  • hardware platform
  • operating system

Example

Output

When we run above command, we will get the following result −

From the output, we can see that the Linux kernel version is 4.2.0-27 which is higher than version 3.8, so we are good to go.

Step 2 − You need to update the OS with the latest packages, which can be done via the following command −

This method installs packages from the Internet on to the Linux system.

Syntax

sudo apt-get update

Options

  • sudo − The sudo command is used to ensure that the command runs with root access.

  • update − The update option is used ensure that all packages are updated on the Linux system.

Return Value

None

Example

Output

When we run the above command, we will get the following result −

This command will connect to the internet and download the latest system packages for Ubuntu.

Step 3 − The next step is to install the necessary certificates that will be required to work with the Docker site later on to download the necessary Docker packages. It can be done with the following command.

Step 4 − The next step is to add the new GPG key. This key is required to ensure that all data is encrypted when downloading the necessary packages for Docker.

The following command will download the key with the ID 58118E89F3A912897C070ADBF76221572C52609D from the keyserver hkp://ha.pool.sks-keyservers.net:80 and adds it to the adv keychain. Please note that this particular key is required to download the necessary Docker packages.

Docker Linux Change Image Location

Step 5 − Next, depending on the version of Ubuntu you have, you will need to add the relevant site to the docker.list for the apt package manager, so that it will be able to detect the Docker packages from the Docker site and download them accordingly.

  • Precise 12.04 (LTS) ─ deb https://apt.dockerproject.org/repoubuntu-precise main

  • Trusty 14.04 (LTS) ─ deb https://apt.dockerproject.org/repo/ ubuntu-trusty main

  • Wily 15.10 ─ deb https://apt.dockerproject.org/repo ubuntu-wily main

  • Xenial 16.04 (LTS) - https://apt.dockerproject.org/repo ubuntu-xenial main

Since our OS is Ubuntu 14.04, we will use the Repository name as “deb https://apt.dockerproject.org/repoubuntu-trusty main”.

And then, we will need to add this repository to the docker.list as mentioned above.

Step 6 − Next, we issue the apt-get update command to update the packages on the Ubuntu system.

Step 7 − If you want to verify that the package manager is pointing to the right repository, you can do it by issuing the apt-cache command.

In the output, you will get the link to https://apt.dockerproject.org/repo/

Step 8 − Issue the apt-get update command to ensure all the packages on the local system are up to date.

Step 9 − For Ubuntu Trusty, Wily, and Xenial, we have to install the linux-image-extra-* kernel packages, which allows one to use the aufs storage driver. This driver is used by the newer versions of Docker.

It can be done by using the following command.

Step 10 − The final step is to install Docker and we can do this with the following command −

Here, apt-get uses the install option to download the Docker-engine image from the Docker website and get Docker installed.

The Docker-engine is the official package from the Docker Corporation for Ubuntu-based systems.

In the next section, we will see how to check for the version of Docker that was installed.

Docker Version

To see the version of Docker running, you can issue the following command −

Syntax

Options

  • version − It is used to ensure the Docker command returns the Docker version installed.

Docker Linux Update Container

Return Value

The output will provide the various details of the Docker version installed on the system.

Example

Output

When we run the above program, we will get the following result −

Docker Info

To see more information on the Docker running on the system, you can issue the following command −

Syntax

Options

  • info − It is used to ensure that the Docker command returns the detailed information on the Docker service installed.

Return Value

The output will provide the various details of the Docker installed on the system such as −

Docker Update Linux Command

  • Number of containers
  • Number of images
  • The storage driver used by Docker
  • The root directory used by Docker
  • The execution driver used by Docker

Example

Output

When we run the above command, we will get the following result −

Docker for Windows

Docker has out-of-the-box support for Windows, but you need to have the following configuration in order to install Docker for Windows.

System Requirements

Windows OSWindows 10 64 bit
Memory2 GB RAM (recommended)

You can download Docker for Windows from − https://docs.docker.com/docker-for-windows/

Docker ToolBox

Docker ToolBox has been designed for older versions of Windows, such as Windows 8.1 and Windows 7. You need to have the following configuration in order to install Docker for Windows.

Docker Linux Change Directory

Linux

System Requirements

Windows OSWindows 7 , 8, 8.1
Memory2 GB RAM (recommended)
VirtualizationThis should be enabled.

You can download Docker ToolBox from − https://www.docker.com/products/docker-toolbox