In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how Docker buildx builds multi-platform images and pushes them to private repositories. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Introduction
Recently, it has been found that there is also an ARM version of the image on the ARM version of Docker,hub.docker.com, but the construction of the ARM version of the Docker image is a problem. Embedded programs can be cross-compiled on PC. I don't know if there is a cross-build scheme for Docker.
Scheme
At present, there are several ways for Docker to build ARM images. The third is similar to cross-compilation.
Using the ARM host, installing the ARM version of Docker,docker build is the image of the ARM version.
Use Linux's virtualization software to simulate ARM chip + Linux, such as qemu.
Using the Docker experimental feature buildx, you can build multi-platform images.
Using Docker buildx to build multiple platform images
Refer to the following links.
Https://docs.docker.com/engine/reference/commandline/manifest/
Https://docs.docker.com/buildx/working-with-buildx/
Https://engineering.docker.com/2019/06/getting-started-with-docker-for-arm-on-linux/
Two docker test functions are used, and the test function needs to be turned on when in use.
Docker manifest,manifest is a file that contains image information. Manifest list is an image inventory list, which is used to store image information of different os/arch. We can create a manifest list to point to two images, and then we can support multiple platforms.
Docker buildx,buildx is a plug-in for docker and a next-generation docker image build. The plug-in translates instruction sets from different platforms through qemu-user-static to run programs on other platforms on x64. Buildx actually uses moby/buildkit:buildx-stable-1 images for multi-platform construction.
Build a multi-platform version of docker registry
Refer to the link below to build a docker registry image.
Https://community.arm.com/developer/tools-software/tools/b/tools-software-ides-blog/posts/deploying-multi-architecture-docker-registry
Set up dns server to solve buildx bug
The buildx plug-in does not go to the local hosts file, but must go to dns. This is a bug, https://github.com/docker/buildx/issues/218, and no one in the community cares.
Solution: self-built dns, point the address of the image buildx.com to the registry machine, and then use nginx. Ubuntu has a default systemd-resolved, which turns on dnsmasq after closing it.
Using nginx agents to solve naming problems
Add nginx agent to support both HTTP and HTTPS. The plug-in buildx forcibly used HTTPS and couldn't find a place to close it.
Prompt the certificate problem, the certificate does not belong to this domain name, the solution: regenerate a certificate, fill in your own domain name.
Certificate problems, do not trust self-signed certificates, add self-signed certificates to the certificate trust chain of the buildx daemon container. Https://github.com/docker/buildx/issues/80#issuecomment-533844117
Nginx adds two configurations to solve several problems with client-side push.
# nignx.conf configuration proxy_ignore_client_abort on; # ignore client alarm client_max_body_size 0; # upload file size is not limited # Virtual host configuration server {listen 443; server_name buildx.com; ssl on; ssl_certificate crt/server.crt; ssl_certificate_key crt/server.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 # configure ssl_ciphers ECDHER http://192.168.1.11:81; server AES128 Musi GCM SHA256 ssl_ciphers HIGHVUR Null "MD5V" RC4HD "DHEX" according to this protocol # configure ssl_prefer_server_ciphers on; location / {ECDHEML}} server {listen 80; server_name buildx.com; location / {proxy_pass RCM}} according to this suite
Set up the local Docker environment
The local Docker needs to enable the experimental function.
Configure "experimental": true in / etc/docker/daemon.json, and restart Docker. Turn on the experimental function of Docker daemon.
Execute export DOCKER_CLI_EXPERIMENTAL=enabled locally and turn on the experimental function of Docker Client.
Use docker version to see if the lab function is turned on.
Execute docker run-- rm-- privileged docker/binfmt:820fdd95a9972a5308930a2bdfb8573dd4447ad3, turn on the kernel binfmt_misc function, and execute multi-platform programs on the current platform.
See if the aarch74 program is supported. Cat / proc/sys/fs/binfmt_misc/qemu-aarch74
At this point, the local docker can run docker containers for various platforms. Like arm64. You can use the following command to test.
# pull the arm64 version image and run docker pull-- platform arm64 alpine:3.10docker run-- rm-it alpine:3.10 sh
Create a basic image
You can get versions of multiple platforms from hub.docker.com, generate manifest list, and upload it to registry.
# pull arm64 version, rename, upload. For more information on whether the image supports multiple platforms, you can see it on hub.docker.com. Docker pull-- platform arm64 centos:7docker tag centos:7 buildx.com/base/centos-arm64:7docker push buildx.com/base/centos-arm64:7# pull amd64 version, rename, upload docker pull-- platform amd64 centos:7docker tag centos:7 buildx.com/base/centos-amd64:7docker push buildx.com/base/centos-amd64:7# create manifest list, upload. Docker manifest create-insecure buildx.com/base/centos:7 buildx.com/base/centos-amd64:7 buildx.com/base/centos-arm64:7docker manifest push-insecure buildx.com/base/centos:7
Build a business image
# buildx can specify multiple platforms, but the FROM image in Dockerfile must have a corresponding version. # buildx packaged images will not be stored locally. Add-- push, and upload the docker repository. Or you can use-- output to specify the output mode. Docker buildx build-platform linux/amd64,linux/arm64-t buildx.com/base/java-base:openjdk-8-centos7. -- push Thank you for your reading! This is the end of the article on "how to build multi-platform images and push Docker buildx to private repositories". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.