Introduction to Docker Multi-arch Cross-platform Building(Duration: 5 mins)
You are an IT manager. Recently, the data center under your management purchased a batch of LinuxONE machines, and you need to quickly migrate the container applications on the x86 platform to the LinuxONE platform. Therefore, you come to this Online Lab for learning and performing the experiment:
(This experiment is also applicable for: Quickly migrate container applications on a x86 platform to a z/OS Container Extensions environment)
The emergence of container technology and Docker Multi-arch cross-platform container technology has addressed the strong coupling relationship between the application system and the supporting hardware environment of the middleware system to a very large extent, and has replaced virtual machines and become an important support for cloud native systems.
Meanwhile, although container technology Docker and the host share the kernel, its underlying implementation mechanism (NameSpace + ControlGroup + UnionFileSystem) still relies on Linux and the underlying hardware platform. As a result, one application has to use different Docker images on different hardware platforms, which need to be separately built on different hardware platforms, causing increases in environment complexity and the workload of continuous integration (CI) in DevOps.
Docker Multi-arch cross-platform building solves this problem. You can build Docker Images on the ARM platform and the LinuxONE platform on a x86 platform. (https://github.com/multiarch/qemu-user-static/)
Therefore, they can share the same continuous integration pipeline (CI Pipeline) with x86 Docker Images, which not only simplify the environment and process, but also improve the quality and efficiency of delivery.

The above s390x medium is suitable for a LinuxONE platform environment or a z/OS Container Extensions environment.
In this online experiment, we will integrate a docker image of s390x on the x86 platform quickly based on an existing x86 Docker Image sample with this cross-platform building feature.
Log into the experimental environment, and then view and run the existing x86 Docker Image building sample(Duration: 8 mins)
Enter uname -a
and you will see the local x86 Linux, as shown below:
Linux cscdemo-virtual-machine 5.3.0-53-generic #47~18.04.1-Ubuntu SMP Thu May 7 13:10:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Enter cd ~/multiarch
to enter the multiarch directory.
Check the Python code of the sample. The output of this sample is the hardware platform where the docker is running.
Enter cat src/hello.py
and the output is shown in the following figure.
Check the dockerfile, which is the definition file for the Docker image running on the x86 platform.
Enter cat Dockerfile
and the output is shown in the following figure.
View the building and running script: dockerBldRun.sh.
Enter cat dockerBldRun.sh
and the output is shown in the following figure.
Run and check the output of docker running output.
Enter ./dockerBldRun.sh
Open the browser and enter address http://0.0.0.0:5000, and the following output will be generated: We can see that this application is running on the x86 hardware.

Get back to the command line interface and exit from the current script with the key combination Ctrl+C
Build LinuxONE Docker Image quickly and run tests(Duration: 12 mins)
(1) Check Dockerfile.s390x.
Enter cat Dockerfile
and cat Dockerfile.s390x
The upper part is a x86-based Dockerfile, and the lower part can be made to support the LinuxONE platform by simply modifying two lines. Where:
FROM s390x/python:3.7-alpine as base
The basic images of Python are images supported by different platforms and required for building LinuxONE, and platform support of s390x is necessary. IBM Z on the official website of dockerhub refers to the platform support.

COPY qemu-s390x-static /usr/bin/
This sentence is the key to multi-platform support. Through multiarch/qemu, it is possible to directly build LinuxONE container images on x86 across platforms without logging onto the LinuxONE platform.
(2) Execute building script dockerBldRun.s390x.sh.
Enter ./dockerBldRun.s390x.sh
When building a container image, it is necessary to obtain the latest qemu version first, and then unpack it and run a virtual container with heterogeneous support.
Then start to build the LinuxONE container image:
docker build -f Dockerfile.s390x -t ${cscRepo}/`whoami`multiarch:s390x .
We can see that it is not much different from building a x86 platform container image, except for the use of Dockerfile.s390x in the first step. (Please note that in order to distinguish the s390x medium from the x86 medium, the s390x tag is used here)
After the container image is pushed to the warehouse, you can use the image like those on other platforms.
When you see a piece of information similar to the following one, it means that the docker image corresponding to s390x has been successfully built and incorporated into the library.
s390x: digest: sha256:6aadffdd5cdee6adeca9936d49f2ea4ca0ebe4928bb891d4e6f0838c6cb431e4 size: 1786
(3) Finally, use the ssh command to access the remote machine (domain name: linuxone), run the image and execute the uname -a command remotely, and then you can see that the remote machine has an s390x architecture.
Enter ssh zj2c@linuxone "uname -a"
The following information will be displayed.
Linux bz0512 3.10.0-957.el7.s390x #1 SMP Thu Oct 4 16:53:20 EDT 2018 s390x s390x s390x GNU/Linux
Run the docker application remotely.
Enter ssh zj2c@linuxone "docker run -p ${dockerPort}:5000 --name=`whoami` ${cscRepo}/`whoami`multiarch:s390x"
The output is described as follows:
Open the browser and enter the address: http://linuxone:500x, and then we can see the operation result as shown in the following figure.
Note 1: It is being executed on a remote machine, so the IP address should be the domain name of the remote machine, linuxone, instead of 0.0.0.0.
