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

Doesn't use socket from current docker context #412

Open
bzoks opened this issue Jul 24, 2022 · 4 comments
Open

Doesn't use socket from current docker context #412

bzoks opened this issue Jul 24, 2022 · 4 comments

Comments

@bzoks
Copy link

bzoks commented Jul 24, 2022

In Docker Desktop (for Linux), when trying to analyze local image, dive doesn't use current docker context endpoint (socket), but apparently always uses "default" endpoint (/var/run/docker.sock), which means it fails to access images built under Docker Desktop environment.
Example:
Docker Desktop turned off. Built an image. I'm able to analyze it:

$ dive 627547a71182
Image Source: docker://627547a71182
Fetching image... (this can take a while for large images)
Analyzing image...
Building cache...

When I start Docker Desktop (or switch docker context), this same image is still accessible by dive, even if it is not available for docker (under current context):

$ docker image inspect 627547a71182
[]
Error: No such image: 627547a71182

When listing images from current (Docker Desktop) context, listed-ones are not accessible to dive:

$ docker image ls
REPOSITORY                                                          TAG          IMAGE ID       CREATED         SIZE
something_phpfpm-pa                                                latest       36328f223adc   11 hours ago    114MB

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

Output of docker context ls:

$ docker context ls
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                    KUBERNETES ENDPOINT   ORCHESTRATOR
default             moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                                              swarm
desktop-linux *     moby                                                          unix:///home/bostjan/.docker/desktop/docker.sock                         
ecs-prod            ecs  

(asterix on desktop-linux line shows which context is current, so which will be used for all docker commands).

I tried also running dive using docker run and mounting correct endpoint (so the one from current context), but it still didn't worked...

More info on docker contexts in scope of Docker Desktop: Switch between Docker Desktop and Docker Engine

@thediveo
Copy link

bump: please make the Docker REST API endpoint configurable on CLI, so that dive can also be directly used with other engines, such as podman that support the Docker REST API; these tend to run on their own socket API paths in order to allow side-by-side co-existance.

@kizdebski
Copy link

Hi.

I have just faced with this problem.
Use this environment variable to change default socket.
DOCKER_HOST=unix:///home/kamil/.docker/desktop/docker.sock

Of course home catalog may be different :)

@tomharrisonjr
Copy link

On macos, if you have Advanced/User settings ("Choose how to configure the installation of Docker's CLI tools"), you'll need to do this to make local builds work:

export DOCKER_HOST=unix:///Users/yourusername/.docker/run/docker.sock

@vit-kolmakov
Copy link

Unfortunately, setting the $DOCKER_HOST variable conflicts with docker context AFAIK.

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.

joschi added a commit to joschi/dive that referenced this issue Nov 7, 2024
…oodman#490)

This patch adds support for detecting the "docker host" to connect to which is set in the current docker context.
One can have multiple such contexts and one of them can be activated via `docker context use <context-name>`.

Fixes wagoodman#397
Fixes wagoodman#408
Fixes wagoodman#412
Fixes wagoodman#463
Fixes wagoodman#495

Co-authored-by: Rajiv Kushwaha <raj25by10@gmail.com>
joschi added a commit to joschi/dive that referenced this issue Nov 7, 2024
…oodman#490)

This patch adds support for detecting the "docker host" to connect to which is set in the current docker context.
One can have multiple such contexts and one of them can be activated via `docker context use <context-name>`.

Fixes wagoodman#397
Fixes wagoodman#408
Fixes wagoodman#412
Fixes wagoodman#463
Fixes wagoodman#495

Co-authored-by: Rajiv Kushwaha <raj25by10@gmail.com>
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

5 participants