Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get the SHA / Container ID of failed builds #424

Closed
2 tasks done
sindre-nistad opened this issue Oct 20, 2020 · 6 comments
Closed
2 tasks done

How do I get the SHA / Container ID of failed builds #424

sindre-nistad opened this issue Oct 20, 2020 · 6 comments

Comments

@sindre-nistad
Copy link

  • I have tried with the latest version of my channel (Stable or Edge)
  • I have uploaded Diagnostics
  • Diagnostics ID: 186430DE-AC01-457C-A70E-BEDB4F520049/20201020074455

Expected behavior

Be able to find the container ID of failed builds, so that I can log enter them interactively, and debug them.

Actual behavior

=> ERROR [build x/n] RUN <failed command>

Information

  • macOS Version: 10.15.7

Diagnostic logs

Docker for Mac: version...

Steps to reproduce the behavior

  1. ...
  2. ...
@stephen-turner
Copy link

I'm not sure I understand the question. If the build failed, there is no container to inspect.

@sindre-nistad
Copy link
Author

There should be an intermediate container. At least it was earlier (and may still be in the stable release).

From "Examples/Build with PATH"

$ docker build .

Uploading context 10240 bytes
Step 1/3 : FROM busybox
Pulling repository busybox
 ---> e9aa60c60128MB/2.284 MB (100%) endpoint: https://cdn-registry-1.docker.io/v1/
Step 2/3 : RUN ls -lh /
 ---> Running in 9c9e81692ae9
total 24
drwxr-xr-x    2 root     root        4.0K Mar 12  2013 bin
drwxr-xr-x    5 root     root        4.0K Oct 19 00:19 dev
drwxr-xr-x    2 root     root        4.0K Oct 19 00:19 etc
drwxr-xr-x    2 root     root        4.0K Nov 15 23:34 lib
lrwxrwxrwx    1 root     root           3 Mar 12  2013 lib64 -> lib
dr-xr-xr-x  116 root     root           0 Nov 15 23:34 proc
lrwxrwxrwx    1 root     root           3 Mar 12  2013 sbin -> bin
dr-xr-xr-x   13 root     root           0 Nov 15 23:34 sys
drwxr-xr-x    2 root     root        4.0K Mar 12  2013 tmp
drwxr-xr-x    2 root     root        4.0K Nov 15 23:34 usr
 ---> b35f4035db3f
Step 3/3 : CMD echo Hello world
 ---> Running in 02071fceb21b
 ---> f52f38b7823e
Successfully built f52f38b7823e
Removing intermediate container 9c9e81692ae9
Removing intermediate container 02071fceb21b

In my case, one of the RUN commands fails, and I'd like to run docker run --rm -it <container ID> bash.

Let's say, that in the above example CMD echo Hello world fails for some reason (or that it was a RUN command instead).
Then I'd like to run docker run --rm -it b35f4035db3f sh in order to interactively inspect the content of the container, and try different commands.
This is especially useful when compiling some software, and the configuring, or compilation fails.

@stephen-turner
Copy link

Apologies, I didn't know that was possible.

We recently switched from legacy build to buildkit, which may explain the difference. If you switch back to legacy build in Preferences-Engine, do you get the behaviour you were hoping for?

@sindre-nistad
Copy link
Author

sindre-nistad commented Oct 21, 2020

Yes.

Though, I'd like to have the option for see the container ID in BuildKit as well (docker build --verbose ., or docker build --show-ids ., or something similar).

For one thing, switching back takes some time (i.e. restarting Docker), and the image has to be rebuilt (at least, that's what happened now).

@stephen-turner
Copy link

OK, I'm going to move this ticket into the buildx repo as that code is all upstream of us.

@stephen-turner stephen-turner transferred this issue from docker/for-mac Oct 21, 2020
@tonistiigi
Copy link
Member

Follow updates on this in moby/buildkit#1472 . Current best workaround is to set --target to point to a previous command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants