container-diff icon indicating copy to clipboard operation
container-diff copied to clipboard

Respect `docker context`

Open MPV opened this issue 2 years ago • 1 comments

Expected behavior

$ container-diff analyze daemon://alpine:latest

-----Size-----

Analysis for alpine:latest:
IMAGE                DIGEST                                                                         SIZE
alpine:latest        sha256:aea8c02625caa3b34db828bd3c308230aa173150e3c976a669bdba561225b72c        7M

Actual behavior

$ container-diff analyze daemon://alpine:latest
ERRO[0000] error retrieving image daemon://alpine:latest: retrieving image from daemon: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Information

  • container-diff version: 0.17.0 built from git (unknown)
    • (from brew install container-diff
  • Operating system: macOS Sonoma

Steps to reproduce the behavior

  1. Given that I have these "Docker contexts":
$ docker context ls
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/vs/.docker/run
  1. ...and my default doesn't work:
$ docker --context default ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
  1. ...but my desktop-linux (from Docker Desktop for Mac) works:
$docker --context desktop-linux ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
  1. And desktop-linux is my current one:
$ docker context show
desktop-linux
  1. container-diff should use the current context.

Workarounds

Setting DOCKER_HOST manually works for now:

$ DOCKER_HOST="tcp://0.0.0.0:2375" container-diff analyze daemon://alpine:latest

-----Size-----

Analysis for alpine:latest:
IMAGE                DIGEST                                                                         SIZE
alpine:latest        sha256:aea8c02625caa3b34db828bd3c308230aa173150e3c976a669bdba561225b72c        7M

MPV avatar Oct 03 '23 12:10 MPV

I found another workaround for this: changing (Docker for Mac's config) back from the new default into the older default socket path, as per:

  • https://docs.docker.com/desktop/mac/permission-requirements/#installing-symlinks

MPV avatar Dec 18 '23 11:12 MPV