crazy-max / ghaction-setup-docker

GitHub Action to set up (download and install) Docker CE
https://github.com/marketplace/actions/docker-setup-docker
Apache License 2.0
28 stars 3 forks source link

Unable to talk to Docker with Go client on Mac #4

Closed verdverm closed 1 year ago

verdverm commented 1 year ago

Behaviour

Steps to reproduce this issue

go run main.go on a macos-latest runner after this action

https://github.com/hofstadter-io/hof/blob/ci-docker/test/docker/main.go

Expected behaviour

The Go client should be able to query and start containers on macos

Actual behaviour

Error getting versions: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Configuration

https://github.com/hofstadter-io/hof/blob/3e100d5604eb7bf983499b13d21637283fff6158/.github/workflows/hof.yml#L52

Logs

https://github.com/hofstadter-io/hof/actions/runs/4321103204/jobs/7541988936

crazy-max commented 1 year ago

Remove this: https://github.com/hofstadter-io/hof/blob/451d5563b470bf57ef278b977f12b396af65c72a/.github/workflows/hof.yml#L57-L58

This action already sets the right Docker context: https://github.com/hofstadter-io/hof/actions/runs/4321103204/jobs/7541988936#step:8:264

verdverm commented 1 year ago

Sorry, I did not get perma-links, I have added those since creating this. It was not working without them

I don't think the Go client is working with non-default contexts, or I haven't figured out how to use the current selected one

crazy-max commented 1 year ago

Sorry, I did not get perma-links, I have added those since creating this. It was not working without them

I don't think the Go client is working with non-default contexts, or I haven't figured out how to use the current selected one

You don't need to enforce DOCKER_HOST here:

      - name: Setup Docker MacOS var
        run: echo "DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"" >> $GITHUB_ENV
verdverm commented 1 year ago

Apparently the Go client doesn't understand the docker contexts that the docker cli manages. https://github.com/moby/moby/discussions/44166

I think the only way to get this to work with the Go client is to use the DOCKER_HOST variable. https://github.com/hofstadter-io/hof/actions/runs/4321103204/jobs/7541988936#step:10:97

The correct value is DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"

crazy-max commented 1 year ago

Oh my bad, didn't catch you were using the Go client. Then yes setting DOCKER_HOST should do the trick.

verdverm commented 1 year ago

It's now failing when talking to the containers. Do I have to do anything different with ports?

https://github.com/hofstadter-io/hof/actions/runs/4321328600/jobs/7542436289#step:19:247

crazy-max commented 1 year ago

Sorry I don't know you codebase. If you have a simple repro, happy to take a look.

verdverm commented 1 year ago

I ended up just needing to ensure the DOCKER_HOST was propagated to the proper test setups. All is good now. Thanks for making this and pointing me at this project from my other issues.