简体   繁体   中英

Docker build failure -- how to run image by sha256 hash?

I'm getting an error when trying to build one of my Dockerfiles,

❯ docker build --build-arg env=development . --progress=plain
#1 [internal] load build definition from Dockerfile
#1 sha256:c3c9b42a729c6c2731ead1895724c3f53c55d67fe58c7ce2fcd2093556b293d6
#1 transferring dockerfile: 32B 0.0s done
#1 DONE 0.0s

...

#8 [4/4] RUN yarn install --frozen-lockfile --production=false --non-interactive
#8 sha256:82e644b842f91e7584561a70e10518eaa645543d3d7a525140f5e26c4e93ea0d
#8 0.318 yarn install v1.22.19

...

#8 ERROR: executor failed running [/bin/sh -c yarn install --frozen-lockfile --production=false --non-interactive]: exit code: 1
------
 > [4/4] RUN yarn install --frozen-lockfile --production=false --non-interactive:
------
executor failed running [/bin/sh -c yarn install --frozen-lockfile --production=false --non-interactive]: exit code: 1

I assume sha256:82e644b842f91e7584561a70e10518eaa645543d3d7a525140f5e26c4e93ea0d is the image it's trying to run yarn install in, yet when I try

$ docker run --rm -it --entrypoint sh a45dc5a92caf2f0a57593e5181c60e4fbe1f6a32ae8aa5e1cbaf30a2bd005407 -c '{ command -v zsh && exec zsh -il ;} || { command -v bash && bash -il ;} || { command -v ash && ash -il ;}'
docker: Error response from daemon: No such image: sha256:a45dc5a92caf2f0a57593e5181c60e4fbe1f6a32ae8aa5e1cbaf30a2bd005407.
See 'docker run --help'.

How do I get the actual image name or hash just before the build failure so that I can docker run it?

I believe it's using buildkit but I'm unsure how to verify. I do want buildkit.

You have pointed the root cause that is the Buildkit build system

Buildkit does not create intermediate images nor make the containers it runs visible in docker run (both for very good reasons).
-- source

There is a proposal to address this need that is in progress at the time of writing.

Alternative solutions to perform debugging with Buildkit:

  • Use targets to do a partial build and the debug the output of it, as described in this answer .
  • Use the buildg interactive debugger.

Maybe the buildctl command of Buildkit can be used to perform debug but I have not checked in detail,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM