Dockerhub has many official images and supports multiple platforms. This article gives a brief introduction.

download

For example, the official address of busyBox is hub.docker.com/_/busybox?t… . You can view various versions for various platforms. See Figure 1.

Download an ARM V7 version:

docker pull busybox:glibc@sha256:783d05e2c73f48d4499387b807caf11b0b3afef5e17e225643b4b4558b21e221
Copy the code

Through the docker images | grep busybox view its image with ID 2128 ff41e8e1. As follows:

Busybox < None > 2128FF41e8e1 12 days ago 2.68 MBCopy the code

Only the mirror ID, no mirror name, labeled:

docker tag 2128ff41e8e1 latelee/armbusybox:v7
Copy the code

This image will not run on x86. Tip:

standard_init_linux.go:178: exec user process caused "exec format error"
Copy the code

Docker version 19.03 already supports building multi-platform images. No experiment for some reason.

upload

In the previous section, we specified the value of sha256 when pulling images to show the difference. In fact, docker pull can select different images based on the current system, using the nginx command as an example:

docker pull nginx
Copy the code

Run on different systems (such as ARM, x86, and X86_64), and the resulting images are different and match the current system. Because the official nginx supports different systems, see hub.docker.com/_/nginx?tab… . This benefits the Docker Manifest mechanism.

The following is an attempt to make an image that supports multiple platforms. For users, the image name is the same, and docker selects the image according to the architecture when the command is executed.

1. Open experimental features:

export DOCKER_CLI_EXPERIMENTAL=enabled
Copy the code

2. Make different images.

3. Upload the image

docker push latelee/webgin latelee/amd64webgin
docker push latelee/webgin latelee/armwebgin
Copy the code

4, production first create:

# docker manifest create latelee/webgin latelee/amd64webgin latelee/armwebgin
Created manifest list docker.io/latelee/webgin:latest
Copy the code

Label different platforms:

docker manifest annotate latelee/webgin latelee/amd64webgin --os linux --arch x86_64docker manifest annotate latelee/webgin latelee/armwebgin --os linux --arch armv7l
Copy the code

For details:

docker manifest inspect latelee/webgin
Copy the code

Last push:

docker manifest push latelee/webgin
Copy the code

Note 1: In different system experiments, found that the arch field name is different, sometimes x86_64 is ok, but sometimes amd64 is ok, some examples: ARM, PPC64LE, arm64. Note 2: If the manifest has been incorrectly created, the manifest cannot be updated. Solution: Find a new machine and start again. Note 3: It does not need to be downloaded locally, but it does need to exist on dockerHub. The image does seem to exist on the DockerHub. Note 4: The DockerHub network is not very stable due to a week’s knowledge and may require multiple attempts.

If it does not exist, it cannot be downloaded. For example, the ARM version does not exist, but is pulled from the ARM system:

docker pull latelee/webginlatest: Pulling from latelee/webginlatest: Pulling from latelee/webginlatest: Pulling from latelee/webginno matching manifest for linux/arm in the manifest list entries
Copy the code