How much does Docker virtualize?

Hi,
I was under the assumption that Docker does provide a virtualization layer that is independant of the underlying hardware architecture, but it seems this is not the case. Indeed, I ported an image to a s390 and it would not start ("exec user process caused “exec format error”). When checking the image ("docker inspect --format “{{.Os}} {{.Architecture}}” ") it would return “linux amd64”.
Do images have to be purpose built on a specific architecture? If an image is built for a given architecture, is there a way to obtain the image for another architecture?
Thanks for any insights you may provide.
Christian

It does not provide machine virtualisation.

It is offen called application virtualization as it allows to create images, that can be used on same architecture among OS that share a kernel compatibility. E.g. your docker engine could run on a Ubuntu host and inside your Containers any Linux distribution could be used like RHEL, Alpine, Suse, … Tough, in reality it is “just” leveraging existing kernel functions and moduls along with some low level tools that deal with network, storage and resource encapulation. Docker “just” replaced the pain of orchestrating all those aspects yourself with an easy to use commandline interface :slight_smile:

Such an image contain all aspects required by the encapsulated service: a minimal os, an application or service, all dependencies and all required configurations.

I assume your need to use base images for the s390x architecture:
https://hub.docker.com/search/?type=image&architecture=s390x

Thanks Meyay for the response and detailed explanation. Christian

Did it work for you, I still facing some issue.

Hi.

A container built on one architecture will not run on another.
Way back when with Docker “you could run a container anywhere you want, as long as it is the x86_64 CPU architecture on Linux.” Now Docker runs on other architectures and Operating Systems besides Linux on x86-64: IBM Z (s390x), IBM Power, ARM, ARM64. Also Docker on Windows is supported and Docker for Windows can run Windows containers and Linux Containers (Linux containers on Windows 10 | Microsoft Learn). Linux cannot run Windows containers.

Docker containers built for those architectures can only on the Docker installed on those architectures.
Many of the Docker Official Images have images that run on multiple Architectures.
Nginx is one.

https://hub.docker.com/_/nginx

And Docker came out with a new image manifest type V2 called the “Fat Manifest” or manifest list.
An image builder can create a docker image for each platform they support, push the images to a repository and then create a “Fat Manifest” and push that to the repository. The Fat Manifest lists the architectures that the docker image will run on. The Fat Manifest makes it easy for a user to pull the image.

If a docker image has a “Fat Manifest” and the docker image is supportted on lets say x86-64 and IBM Z, then all you need to to is issue a docker image pull for the docker image. Docker will check to see if there is a Fat Manifest entry for the architecture you are pulling from and if so will pull the image for that architecture.

Example of Nginx’s Fat Manfiest

The get_docker_image_manifest_list is a script I wrote. https://github.com/gforghetti/docker_registry_api_bash_functions

$ get_docker_image_manifest_list -i library/nginx:latest | jq -r '.manifests[].platform'
{
  "architecture": "amd64",
  "os": "linux"
}
{
  "architecture": "arm",
  "os": "linux",
  "variant": "v7"
}
{
  "architecture": "arm64",
  "os": "linux",
  "variant": "v8"
}
{
  "architecture": "386",
  "os": "linux"
}
{
  "architecture": "ppc64le",
  "os": "linux"
}
{
  "architecture": "s390x",
  "os": "linux"
}

Examples

Ubuntu Linux x86-64

🐳  root@172.16.129.75:[~] $ uname -a
Linux manager.example.com 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

🐳  root@172.16.129.75:[~] $ docker version
Client:
 Version:           18.09.1
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        20b6775
 Built:             Wed Jan  9 16:50:48 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Enterprise
 Engine:
  Version:          18.09.1
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       20b6775
  Built:            Wed Jan  9 16:34:38 2019
  OS/Arch:          linux/amd64
  Experimental:     false

🐳  root@172.16.129.75:[~] $ docker image pull nginx:latest
manager.example.com: Pulling nginx:latest...
manager.example.com: Pulling nginx:latest... : Pulling from library/nginx
manager.example.com: Pulling nginx:latest... : Pull complete
manager.example.com: Pulling nginx:latest... : Digest: sha256:3d7a756fbaa821a5835d6cef14c6d84183bdc2d808750121833f4611733df45e
manager.example.com: Pulling nginx:latest... : Status: Downloaded newer image for nginx:latest
manager.example.com: Pulling nginx:latest...

🐳  root@172.16.129.75:[~] $ docker image inspect nginx:latest --format '{{.Os}} {{.Architecture}}'
linux amd64

IBM Z

🐳  gforghetti:[~] $ ssh linux1@148.100.33.181
Warning: Permanently added '148.100.33.181' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-131-generic s390x)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

31 packages can be updated.
0 updates are security updates.


*** System restart required ***
Last login: Thu Nov  2 13:39:06 2017 from 45.18.37.41

linux1@lxdoc01:~$ uname -a
Linux lxdoc01 4.4.0-131-generic #157-Ubuntu SMP Thu Jul 12 15:44:42 UTC 2018 s390x s390x s390x GNU/Linux

linux1@lxdoc01:~$ docker version
Client: Docker Enterprise Edition (EE) 2.0
 Version:      17.06.2-ee-16
 API version:  1.30
 Go version:   go1.8.7
 Git commit:   9ef4f0a
 Built:        Thu Jul 26 16:40:41 2018
 OS/Arch:      linux/s390x

Server: Docker Enterprise Edition (EE) 2.0
 Engine:
  Version:      17.06.2-ee-16
  API version:  1.30 (minimum version 1.12)
  Go version:   go1.8.7
  Git commit:   9ef4f0a
  Built:        Thu Jul 26 16:39:59 2018
  OS/Arch:      linux/s390x
  Experimental: false

linux1@lxdoc01:~$ docker image pull nginx:latest
latest: Pulling from library/nginx
99e7bb47d7df: Pull complete
2664bbd6f1e4: Pull complete
e1743d552386: Pull complete
Digest: sha256:3d7a756fbaa821a5835d6cef14c6d84183bdc2d808750121833f4611733df45e
Status: Downloaded newer image for nginx:latest
linux1@lxdoc01:~$

linux1@lxdoc01:~$ docker image inspect nginx:latest --format '{{.Os}} {{.Architecture}}'
linux s390x

Example of a Multi Architecture Image with a Manifest List.