Reputation: 13
Is there a way to build an image over multi-arch base images (for the runtime), but not specify the cpu architecture? This would be equivalent of .rpm "noarch" or .dep "any" arch.
When building Java and nodejs images, there is often no arch-specific content, and it would be much simpler to provide a single, universal image.
This is different than multi-arch which is building multiple copies of the same image for different architectures with the same name. https://www.docker.com/blog/multi-platform-docker-builds/
Upvotes: 1
Views: 287
Reputation: 158714
This is not technically possible. The complication is not that the program you're trying to run isn't portable, but rather that the Docker image also contains its interpreter, and that isn't portable.
As an absolutely minimal example, consider a Docker image that just runs a shell script:
#!/bin/sh
echo 'Hello, world!'
Its Dockerfile would look portable:
FROM busybox
COPY hello.sh /bin
CMD ["/bin/hello.sh"]
But, the busybox
image is architecture-specific; it contains the compiled binary for the C BusyBox code. Since the derived image is the architecture-specific busybox
base image plus the portable shell script, the resulting image is architecture-specific.
Similar constraints apply around a compiled JVM or Node interpreter. At some point in the image stack you have to get down to some native compiled code that can execute the portable content.
Upvotes: 1