Reputation: 8350
I am new to Docker and container technologies in general so sorry if this is a naive question. Would it possible to just build (not run!) a Windows Docker image from a Linux machine from a Dockerfile?
Upvotes: 1
Views: 5530
Reputation: 159865
For the most part, no, it's not.
The real technical problem you'll run into is that it's almost impossible to build an image without RUN
steps in the Dockerfile. These do, internally, create containers and run them, and you can't run a Windows container without a Windows host. (Where you can apparently run Linux containers on non-Linux hosts, there's either a layer like WSL or a Linux virtual machine involved.)
If you could build an image without RUN
ning anything it might be possible via the Dockerfile FROM --platform=windows/amd64
option, but again, you'd be very limited in what you could actually do.
I could imagine wanting this in a couple of specific scenarios. You'd have to do all of the setup in a platform-independent way outside the container. A Java application, for example, can be fully compiled to a portable .jar
file and then COPY
ed into the final image without RUN
ning anything. I can also imagine a setup building a cross-compiler in an earlier Dockerfile stage (and this is often a pretty hairy exercise) and then COPY
ing a cross-compiled binary into a Windows image. It might be easier to just run Linux images on Windows via WSL, though.
Upvotes: 5