Creating Multi-Architecture Images
Scenarios
When images are required in the x86 and Arm architectures, and different image tags need to be set, you can create multi-architecture images and manage these images of the same tag using the docker manifest command.
Preparations
- Check the Docker version.
Ensure that you use Docker 19.03 or later that supports the manifest extension. Run the following command to view the version:
docker --version
- If your Docker version is earlier than 19.03, set the experimental environment variable.
Open the Docker daemon configuration file /etc/docker/daemon.json.
vim /etc/docker/daemon.json
Change the value of experimental to true. If this field does not exist, add it.
"experimental": true
Save the file and restart Docker to apply the modification.
sudo systemctl restart docker
- Check whether experimental Docker CLI features are enabled.
echo $DOCKER_CLI_EXPERIMENTAL
- If enabled is returned, experimental Docker CLI features are enabled.
- If disabled or no information is returned, experimental Docker CLI features are not enabled.
Procedure
- Build and push two images to the image repository by following the instructions in Creating a JDK8 Base Image and Pushing It to SWR.
docker push ${repository_url}/${organization}/${image_name}:${image_tag}-amd64
docker push ${repository_url}/${organization}/${image_name}:${image_tag}-arm64
- Build a manifest for the multi-architecture images.
- Create a manifest.
docker manifest create --amend --insecure ${repository_url}/${organization}/${image_name}:${image_tag} ${repository_url}/${organization}/${image_name}:${image_tag}-amd64 ${repository_url}/${organization}/${image_name}:${image_tag}-arm64
- Modify the manifest to add arch information.
docker manifest annotate ${repository_url}/${organization}/${image_name}:${image_tag} ${repository_url}/${organization}/${image_name}:${image_tag}-amd64 --arch amd64
docker manifest annotate ${repository_url}/${organization}/${image_name}:${image_tag} ${repository_url}/${organization}/${image_name}:${image_tag}-arm64 --arch arm64
- Create a manifest.
- Push the manifest.
docker manifest push ${repository_url}/${organization}/${image_name}:${image_tag}
Downloading an Image Across CPU Architectures
Use the --platform parameter to specify the architecture of the image to be pulled.
docker pull ${repository_url}/${organization}/${image_name}:${image_tag} --platform=linux/amd64
--platform parameter description:
- --platform=linux/amd64: Linux system of the x86_64 architecture
- --platform=linux/arm64: Linux system of the ARM64 architecture
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot