wagoodman / dive

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

dive with podman on MacOS #368

Closed bhundven closed 1 year ago

bhundven commented 3 years ago

I'm trying to use dive with podman on MacOS.

$ dive version
dive 0.10.0

I'm using a local build of podman, since there was a bug fixed upstream that hasn't been released yet:

$ podman version
Client:
Version:      4.0.0-dev
API Version:  4.0.0-dev
Go Version:   go1.16.2
Git Commit:   c0cde378298bd8d5183155c8f62aae574be069eb-dirty
Built:        Wed Sep 15 09:47:15 2021
OS/Arch:      darwin/amd64

Server:
Version:      3.3.1
API Version:  3.3.1
Go Version:   go1.16.6
Built:        Mon Aug 30 13:46:36 2021
OS/Arch:      linux/amd64

But I guess this setup is still unsupported?

$ dive --source podman docker.io/hello-world
Image Source: podman://docker.io/hello-world
Fetching image... (this can take a while for large images)
cannot fetch image
unsupported platform

I am able to build images using podman with this dev release, and the bug fix for podman on MacOS will be released in podman 3.4 (so, soon).

fxw commented 3 years ago

Any news on this issue ?

seanleblancicdtech commented 2 years ago

Try soft linking your podman to docker binary -

ln -s /usr/local/podman /usr/local/bin/docker

You may have to export your DOCKER_HOST value (podman will print something like this out on podman start) or install podman-mac-helper.

ssbarnea commented 2 years ago

@seanleblancicdtech Doing the symlinking is not needed but exporting the DOCKER_HOST from podman is mandatory in order to fool dive into using podman machine on macos. Basically we do not need to uninstall docker to run dive with podman, but with extra manual hacks, which is clearly far from ideal.

jorisroovers commented 1 year ago

Still running into this but got it to work by setting DOCKER_HOST="ssh://core@localhost:63444", which I found through podman system connection list.

> dive --version && podman --version
dive 0.10.0
podman version 4.3.1

# Not working by default
> dive docker.io/hello-world
Image Source: docker://docker.io/hello-world
Fetching image... (this can take a while for large images)
Handler not available locally. Trying to pull 'docker.io/hello-world'...
Using default tag: latest
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
cannot fetch image
exit status 1

# Find the connection string
> podman system connection list
Name                         URI                                                         Identity                                     Default
podman-machine-default       ssh://core@localhost:63444/run/user/501/podman/podman.sock  /Users/jroovers/.ssh/podman-machine-default  true
podman-machine-default-root  ssh://root@localhost:63444/run/podman/podman.sock           /Users/jroovers/.ssh/podman-machine-default  false

> export DOCKER_HOST="ssh://root@localhost:63444"

# Works now!
> dive docker.io/hello-world

# Also works with local images
> podman build -t myimage .
> dive myimage

# Building images directly via dive doesn't work this way, so need to build them first and then run dive
> dive build -t myimage .
Building image...
Sending build context to Docker daemon  111.7MB
request returned Bad Request for API route and version http://docker.example.com/v1.41/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=myimage&target=&ulimits=null&version=1, check if the server supports the requested API version
cannot build image
exit status 1