I’ve seen lots of examples of multistage builds where the second stage copies files from the first. However, my current situation is a bit different: the first stage generates the actual .tar.gz Docker image I want to use as the base for the second stage. I don’t see a --from= option for FROM in the documentation like there is for COPY. Is it possible to do this with a multistage build?
The Dockerfile reference does not mention any support of FROM --from.
It might be possible by creating a custom syntax that implements the behavior.
Right now, the only thing that works out of the box, is to create the 2nd stage as FROM scratch and then use the COPY --from= instruction to copy the content of the unarchived tar.gz to /.
And of course there is the possibility to open a feature request. Right now I am not sure, in which project the feature request needs to be created. @rimelek Do you happen to know which project is the right one?
Is it an actual image exported into a tar gz file or just the filesystem? If it is an image, I would simply load it first on the host even without a name, which would probably happen anyway when it is implemented as an existing fetaure.
But if a featre request is necessary, all feature requests can go to the roadmap repository
Specifically, I’d like to use Nix’s dockerTools.buildImage, which creates an actual image, to build a minimal-ish container, but I don’t want to require Nix to be installed on the host system. My thought was that, if supported, I could use multistage building with the first stage being the NixOS container to build an image, and then use that built image as the base for the final result.
I realize I can do it with multiple invocations of docker to spin up the first container to build the image, then load the image, then use it as a base, but it would be nice if it could be all wrapped up in a single Dockerfile.
I can understand that, but I don’t know any way with a single Dockerfile and docker build command. Maybe a workaround with a compose file could work, but that would still not be a clear and nice way.