wagoodman / dive

A tool for exploring each layer in a docker image
MIT License
44.53k stars 1.69k forks source link

Cannot analyze through docker desktop #495

Open jamie-at-arkifi opened 5 months ago

jamie-at-arkifi commented 5 months ago

What happened:

I'm trying to analyze a multi-gigabyte local image, and it's just failing with "could not find image config"

🐚 dive myapp:latest
Image Source: docker://myapp:latest
Fetching image... (this can take a while for large images)
cannot fetch image
could not find image config
🐚 dive build .
Building image...
[REDACTED, but apparently successful]

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/9k057vmr8hx8ldwxbgravqng5
cannot build image
could not find image config

What you expected to happen:

Analysis

How to reproduce it (as minimally and precisely as possible):

Honestly, I'm not sure what's going on to begin narrowing it down. It's a 3+GB image and not published to a registry.

Anything else we need to know?:

Some kind of --verbose might make tracking this down easier.

Buildx is being used.

Environment:

jamie-at-arkifi commented 5 months ago

I think this might be a docker desktop thing?

dive python:3.11 doesn't work either.

Running through the container (instead of the brew version) has the same result in both cases.

mark2185 commented 5 months ago

Could you please try building dive from source? Specifically PR #490.

jamie-at-arkifi commented 5 months ago

(Some build instructions would help a bunch.)

Does not seem to--built 326d463 and ~/src/dive/snapshot/dive_darwin_arm64/dive build . seems to be doing the same thing.

mark2185 commented 5 months ago

Download the fork, checkout the right branch from that fork and run go run main.go python:3.11 from the root of the clone.

jamie-at-arkifi commented 5 months ago
jamie@Jamies-MacBook-Pro ~/src/dive 326d463 🐚 go run main.go python:3.11
Image Source: docker://python:3.11
Fetching image... (this can take a while for large images)
cannot fetch image
could not find image config
exit status 1

By "some build instructions would help", I mean "I spent ten minutes fumbling through the makefile and eventually figured it out, which is not a great experience."

mark2185 commented 5 months ago

By "some build instructions would help", I mean "I spent ten minutes fumbling through the makefile and eventually figured it out, which is not a great experience."

Ah, sorry, thought it was aimed at me. I do agree with the sentiment, though.

If you're up for diving deeper into the issue, I'd look at where is the socket for docker-desktop located, try running docker context ls, and pointing the variable in docker_host_unix.go to that.

If not, please let me know, will see what I can do.

jamie-at-arkifi commented 5 months ago
🐚 docker context list
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                     KUBERNETES ENDPOINT   ORCHESTRATOR
default             moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock
desktop-linux *     moby                Docker Desktop                            unix:///Users/jamie/.docker/run/docker.sock
mark2185 commented 5 months ago

Would you kindly try replacing that line indocker_host_unix.go with unix:///Users/jamie/.docker/run/docker.sock and try it with some image again?

jamie-at-arkifi commented 5 months ago
jamie@Jamies-MacBook-Pro ~/src/dive 326d463 🐚 git diff
diff --git a/dive/image/docker/docker_host_unix.go b/dive/image/docker/docker_host_unix.go
index 52dae70..c93781d 100644
--- a/dive/image/docker/docker_host_unix.go
+++ b/dive/image/docker/docker_host_unix.go
@@ -3,5 +3,5 @@
 package docker

 const (
-       defaultDockerHost = "unix:///var/run/docker.sock"
+       defaultDockerHost = "unix:///Users/jamie/.docker/run/docker.sock"
 )
jamie@Jamies-MacBook-Pro ~/src/dive 326d463 🐚 go run main.go python:3.11
Image Source: docker://python:3.11
Fetching image... (this can take a while for large images)
cannot fetch image
could not find image config
exit status 1
mark2185 commented 5 months ago

Alright, thanks!

Until that's fixed I'd recommend saving the image to a file and then passing the archive to dive, should be an example under --help.

rajiv-k commented 5 months ago

FYI, you don't have to change the defaultDockerHost. You can just export DOCKER_HOST with the desired value. For example, export DOCKER_HOST=unix:///Users/jamie/.docker/run/docker.sock as a workaround until #490 is merged.

mark2185 commented 5 months ago

@rajiv-k but if I'm reading it right, it's not working even after changing the host socket.

Yunsang-Jeong commented 4 months ago

@mark2185 try like this :D

sudo ln -s /Users/yunsang/.docker/run/docker.sock /var/run/docker.sock
manuel-koch commented 4 months ago

I have the same problem and sudo ln -s <MY_SOCK_PATH> /var/run/docker.sock results in ln: /var/run/docker.sock: File exists.

tko commented 4 months ago

FWIW with Docker Desktop on Mac it's a symlink in /var/run

lrwxr-xr-x  1 root  daemon  42 Feb 19 10:12 /var/run/docker.sock -> /Users/test/.docker/run/docker.sock
srwxr-xr-x  1 test  staff    0 Feb 20 20:44 /Users/test/.docker/run/docker.sock

overriding DOCKER_HOST doesn't seem to make any difference for me.