wagoodman / dive

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

[Question] How to use dive with M1 and colima? #408

Open wujek-srujek opened 2 years ago

wujek-srujek commented 2 years ago

I build an image, let's call it new_1:

$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED             SIZE
new_1        latest    f2c3c30fca2d   About an hour ago   179MB
...

and would like to dive into it, but it fails:

$ dive new_1
Image Source: docker://new_1
Fetching image... (this can take a while for large images)
Handler not available locally. Trying to pull 'new_1'...
Using default tag: latest
Error response from daemon: pull access denied for new_1, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
cannot fetch image
exit status 1

What is the exact issue here, and what can I do to make it work (if anything?). It does work with:

docker save new_1 > new_1.tar
dive docker-archive://new_1.tar

that I stole from https://github.com/wagoodman/dive/issues/397#issuecomment-1123061576, but is it the only way?

lincoln-spiteri commented 1 year ago

This works for me

docker context list
export DOCKER_HOST=unix:///<path_to_user_dir>/.colima/default/docker.sock
dive <my_container>

The first command should give you something like:

NAME        DESCRIPTION                               DOCKER ENDPOINT                                            KUBERNETES ENDPOINT   ORCHESTRATOR
colima      colima                                    unix:///Users/lincolnspiteri/.colima/default/docker.sock
default *   Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                                                      swarm

Then set your DOCKER_HOST to the colima Docker endpoint.

wujek-srujek commented 1 year ago

Thanks @lincoln-spiteri , It works but after I set the DOCKER_HOST issuing docker context list show the following warning: Warning: DOCKER_HOST environment variable overrides the active context. To use a context, either set the global --context flag, or unset DOCKER_HOST environment variable. which sounds like it could break some other stuff for me. It is also arguably even more complex than just exporting the tar and diving into that.

tmaier commented 1 year ago

Adding on @lincoln-spiteri:

You can streamline this with $ export DOCKER_HOST=$(docker context inspect --format='{{.Endpoints.docker.Host}}')

docwhat commented 1 year ago

If the engine is set to docker, should dive fetch the DOCKER_HOST itself?

I have the same problem with the Rancher Desktop docker app macOS, and my socket is in ~/.rd/docker.sock

I don't run the bit that needs the administrator access every startup to put the socket in /var/run/docker.sock