wagoodman / dive

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

Unable to connect to docker.sock file while running dive #453

Open hariprasadpo28 opened 1 year ago

hariprasadpo28 commented 1 year ago

I have been trying to run dive on some of my images, after running dive ubuntu:latest I am seeing this error:

Image Source: docker://ubuntu:latest Fetching image... (this can take a while for large images) Handler not available locally. Trying to pull 'ubuntu:latest'... latest: Pulling from library/ubuntu Digest: sha256:dfd64a3b4296d8c9b62aa3309984f8620b98d87e47492599ee20739e8eb54fbf Status: Image is up to date for ubuntu:latest docker.io/library/ubuntu:latest cannot fetch image Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

But I am able to use docker without any problems, docker is also running. OS: MacOS 13.4 Docker engine: v23.0.5

kfrapin commented 1 year ago

Edit 2023-07-10 A better solution is described by @Tantalor93 below https://github.com/wagoodman/dive/issues/453#issuecomment-1627487747

Original proposed solution I had the same problem, but this is not an issue related to dive, this is more related to Docker and how docker.sock seems to be managed on Mac now.

A Docker upgrade on Mac moved the docker.sock from /var/run/ to ~/.docker/run/

An easy fix is:

ln -s ~/.docker/run/docker.sock /var/run/docker.sock

If sudo is required:

sudo ln -s ~/.docker/run/docker.sock /var/run/docker.sock

Note sure how long this fix can work, but for now, it is doing the job!

Tantalor93 commented 12 months ago

If you are using Docker Desktop on Mac, you can enable the option for creating the default Docker socket

image
jmbowman commented 11 months ago

This looks like a change in Docker Desktop 4.18 to allow installation on macOS without needing admin privileges: https://www.docker.com/blog/docker-desktop-4-18/ . It still asks for admin privileges, but if you don't grant them then tools like dive won't work until you enable this new setting.

nigelwtf commented 11 months ago

This could be worth adding as a note to the installation steps. I ran into this issue too!

I haven't used my personal computer in quite a long time for programming. My Docker client updated itself to Docker Desktop - and at no point during the upgrade process did it prompt me for a password (and luckily I kind of stumbled onto this fix myself) 😅

diei commented 11 months ago

I get a similar error since I switched from Docker Desktop to colima at my MacBook (Ventura 13.3.1). Dive (0.11.0) can not load a local image. Docker version is 24.0.4.

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

The post of TG-KK in https://github.com/wagoodman/dive/issues/397#issuecomment-1197249019 helped me.

williamdes commented 1 month ago

For docker rootless: sudo ln -s /run/user/$(id -u)/docker.sock /var/run/docker.sock