Migrate to use docker load/save for helper archives to preserve ENTRYPOINT
The following discussion from !2058 (merged) should be addressed:
-
@steveazz started a discussion: (+4 comments) issue: This isn't going to work for us, unfortunately, because how we are building the Docker image.
We are exporting the image to a tar and when we import it we are going to lose any metadata associated with the image, so we are going to lose the information about the
ENTRYPOINT. We can reproduce this issue withmake helper-dockerarchive-hostand then runningdocker inspecton the image theentrypointis going to benullrather the specified one.This is explained in https://github.com/moby/moby/issues/8334#issuecomment-57471427
docker export and docker import don't preserve metadata. This is by design and it's not being changed.
Now we have to keep exporting the image because we support automatic imports which is useful for offline Runners or Runners that don't have access to the DockerHub registry.
I see two options that we can achieve, but I'm not sure which one is best
Apply changes when importing
We can keep using the tar archive that we create, but then every time we import we have to specify the
ENTRYPOINTlikedocker import --change "ENTRYPOINT [\"/usr/bin/dumb-init\", \"/entrypoint\"]". We need to make this change for make helper-dockerarchive-host and load the image inside of the Docker executor.The only and biggest drawback I see is that we have 3 places where we have to update the
ENTRYPOINTif we want to change this, which is less then ideal. If we have to update it we have to remember to update it elsewhere, we can add a comment in this line to make the user changing the line aware of it.Migrate to save/load
There is another solution, but it's a long road a lot of things can go wrong and it's a breaking change that we would have to deprecate slowly. Using
docker saveinstead ofdocker exportwill save all the metadata of the image, becausedocker saveexports the image and not the container image.We would have to do something like the following:
- Run both
docker exportanddocker saveon the container/image and publish both in our release for examplehelper-images/prebuilt-x86_64.tar.xzandhelper-images/save/prebuilt-x86_64.tar.xz. - Update loadPrebuiltImage or it's caller to call the
docker loadcommand instead ofdocker importifsave/prebult-x86_64.tar.xzis presnet. - Load deprecation warning if we use the
loadon the old tar file that is created bydocker export - In a Major release, we just relay on
docker save/docker loadlogic.
The only drawback that
docker savehas overdocker exportis thetarsize since it's exporting all the Docker layers separately whiledocker exportflattens everything so the tar file is a lot smaller (we need to measure the difference). We also end up with a bigger package overall since we have to ship both tar files at the moment, thedeb/rpmpackages have these bundled up, again we need to measure the difference.
@ggeorgiev_ @tmaczukin @ajwalker @akohlbecker I wonder if we should apply an iterative approach here taking on some ~"technical debt" in favor of shipping this sooner.
- We implement the
--changesproposal inside of this merge request so thatENTRYPOINTworks as expected. - In a follow-up issue we migrate to
save/load
- Run both
Using docker save instead of docker export would also allow us to use the same logic for Windows, which currently doesn't support docker export, and would make running Windows Docker executor tests faster.