As mentioned here, the full docker image tarball is created as an implicit output on demand.
But, what does it mean by on demand? how can I inform the build to produce it?
Seems a lack of documentation here.
As mentioned here, the full docker image tarball is created as an implicit output on demand.
But, what does it mean by on demand? how can I inform the build to produce it?
Seems a lack of documentation here.
You can specify the "image.tar" target name explicitly to build it; for instance, if your container_image target is named my_image in //foo, this will produce the tar archive in bazel-out:
bazel run //foo:my_image.tar
Usually a Docker image is stored within the Docker daemon’s private filesystem space, in a complex format. In ordinary use you’d use docker build, pull, run, and rmi to interact with an image, but none of these result in a file the way building an executable would.
There is an alternate path to managing images using docker save to export an image to a tar file, and docker load to reload it. This is awkward and has a number of disadvantages, and you almost always want to set up a registry or use a hosted registry like Docker Hub given the option.
My read of the documentation you link to is that the Bazel task you link to by default will just run docker build; but, if something downstream of it demands an image.tar file, it will run docker save too. It’s not usually needed and Bazel won’t run it if it’s not.