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

Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? on macOS while docker commands are working #1658

Closed
LenaWil opened this issue Mar 2, 2023 · 15 comments · Fixed by #1745
Labels
kind/bug Something isn't working

Comments

@LenaWil
Copy link

LenaWil commented Mar 2, 2023

Bug report info

act version:            0.2.43
GOOS:                   darwin
GOARCH:                 amd64
NumCPU:                 8
Docker host:            DOCKER_HOST environment variable is unset/empty.
Sockets found:
	/Users/lena/.docker/run/docker.sock
Config files:           
	/Users/lena/.actrc:
		-P ubuntu-latest=catthehacker/ubuntu:act-latest
		-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
		-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
		-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
	Go version:            go1.20.1
	Module path:           command-line-arguments
	Main version:          
	Main path:             
	Main checksum:         
	Build settings:
		-buildmode:           exe
		-compiler:            gc
		-ldflags:             -X main.version=0.2.43
		CGO_ENABLED:          1
		CGO_CFLAGS:           
		CGO_CPPFLAGS:         
		CGO_CXXFLAGS:         
		CGO_LDFLAGS:          
		GOARCH:               amd64
		GOOS:                 darwin
		GOAMD64:              v1

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

Command used with act

act

Describe issue

I expected it to not print Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, because commands like docker ps do work:

CONTAINER ID   IMAGE                    COMMAND                  CREATED         STATUS         PORTS                NAMES
b55271169ff4   docker/getting-started   "/docker-entrypoint.…"   2 minutes ago   Up 2 minutes   0.0.0.0:80->80/tcp   funny_euclid

Link to GitHub repository

LenaWil/Squire@d038cc0

Workflow content

name: Lint Black (official)

# Without review-dog… maybe it’s a bit of waste to make them run twice, but anyway.
on: [push, pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: psf/black@stable

Relevant log output

DEBU[0000] Loading environment from /Users/lena/Documents/Knights/Squire/.env 
DEBU[0000] Loading action inputs from /Users/lena/Documents/Knights/Squire/.input 
DEBU[0000] Loading secrets from /Users/lena/Documents/Knights/Squire/.secrets 
DEBU[0000] Loading workflows from '/Users/lena/Documents/Knights/Squire/.github/workflows' 
DEBU[0000] Loading workflows recursively                
DEBU[0000] Found workflow 'black-review-dog.yml' in '/Users/lena/Documents/Knights/Squire/.github/workflows/black-review-dog.yml' 
DEBU[0000] Found workflow 'black.yml' in '/Users/lena/Documents/Knights/Squire/.github/workflows/black.yml' 
DEBU[0000] Found workflow 'run_tests.yml' in '/Users/lena/Documents/Knights/Squire/.github/workflows/run_tests.yml' 
DEBU[0000] Reading workflow '/Users/lena/Documents/Knights/Squire/.github/workflows/black-review-dog.yml' 
DEBU[0000] Conditional GET for notices etag=89b55634-e474-4cff-a075-2c41abcfb8c3 
DEBU[0000] Reading workflow '/Users/lena/Documents/Knights/Squire/.github/workflows/black.yml' 
DEBU[0000] Reading workflow '/Users/lena/Documents/Knights/Squire/.github/workflows/run_tests.yml' 
DEBU[0000] Preparing plan with all jobs                 
DEBU[0000] Using the only detected workflow event: pull_request 
DEBU[0000] Planning jobs for event: pull_request        
DEBU[0000] Found revision: d038cc03cd0b075071a2ab001ed226c1b3953225 
DEBU[0000] Found revision: d038cc03cd0b075071a2ab001ed226c1b3953225 
DEBU[0000] Found revision: d038cc03cd0b075071a2ab001ed226c1b3953225 
DEBU[0000] Found revision: d038cc03cd0b075071a2ab001ed226c1b3953225 
DEBU[0000]                                              
DEBU[0000] Found revision: d038cc03cd0b075071a2ab001ed226c1b3953225 
ERRO[0000] failed to obtain container engine info: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 
[black-reviewdog/lint      ] [DEBUG] evaluating expression 'success()'
[black-reviewdog/lint      ] [DEBUG] expression 'success()' evaluated to 'true'
[black-reviewdog/lint      ] 🚀  Start image=catthehacker/ubuntu:act-latest
[black-reviewdog/lint      ]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
[black-reviewdog/lint      ] [DEBUG]   🐳  docker pull catthehacker/ubuntu:act-latest
[black-reviewdog/lint      ] [DEBUG] pulling image 'docker.io/catthehacker/ubuntu:act-latest' ()
[Lint Black (official)/lint] [DEBUG] evaluating expression 'success()'
[Lint Black (official)/lint] [DEBUG] expression 'success()' evaluated to 'true'
[Lint Black (official)/lint] 🚀  Start image=catthehacker/ubuntu:act-latest
[Lint Black (official)/lint]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
[Lint Black (official)/lint] [DEBUG]   🐳  docker pull catthehacker/ubuntu:act-latest
[Lint Black (official)/lint] [DEBUG] pulling image 'docker.io/catthehacker/ubuntu:act-latest' ()
[Test Squire/Test Code     ] [DEBUG] evaluating expression 'success()'
[Test Squire/Test Code     ] [DEBUG] expression 'success()' evaluated to 'true'
[Test Squire/Test Code     ] [DEBUG] expression '${{ matrix.ubuntu }}' rewritten to 'format('{0}', matrix.ubuntu)'
[Test Squire/Test Code     ] [DEBUG] evaluating expression 'format('{0}', matrix.ubuntu)'
[Test Squire/Test Code     ] [DEBUG] expression 'format('{0}', matrix.ubuntu)' evaluated to '%!t(string=ubuntu-20.04)'
[Test Squire/Test Code     ] [DEBUG] expression '${{ matrix.ubuntu }}' rewritten to 'format('{0}', matrix.ubuntu)'
[Test Squire/Test Code     ] [DEBUG] evaluating expression 'format('{0}', matrix.ubuntu)'
[Test Squire/Test Code     ] [DEBUG] expression 'format('{0}', matrix.ubuntu)' evaluated to '%!t(string=ubuntu-20.04)'
[Test Squire/Test Code     ] [DEBUG] expression '${{ matrix.ubuntu }}' rewritten to 'format('{0}', matrix.ubuntu)'
[Test Squire/Test Code     ] [DEBUG] evaluating expression 'format('{0}', matrix.ubuntu)'
[Test Squire/Test Code     ] [DEBUG] expression 'format('{0}', matrix.ubuntu)' evaluated to '%!t(string=ubuntu-20.04)'
[Test Squire/Test Code     ] 🚀  Start image=catthehacker/ubuntu:act-20.04
[Test Squire/Test Code     ]   🐳  docker pull image=catthehacker/ubuntu:act-20.04 platform= username= forcePull=true
[Test Squire/Test Code     ] [DEBUG]   🐳  docker pull catthehacker/ubuntu:act-20.04
[Test Squire/Test Code     ] [DEBUG] pulling image 'docker.io/catthehacker/ubuntu:act-20.04' ()
Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Additional information

(On a repo with GitHub workflow actions, this one: LenaWil/Squire@d038cc0 )

There are more workflows, and looking at the debug log it might run some of them? But without verbose mode it prints two error messages.

@LenaWil LenaWil added the kind/bug Something isn't working label Mar 2, 2023
@LenaWil LenaWil changed the title Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? on macOS while docker command are working Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? on macOS while docker commands are working Mar 2, 2023
@culshaw
Copy link

culshaw commented Mar 2, 2023

I don't think this is necessarily an act specific problem, but I've got around this by doing the following:

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

This isn't guaranteed to fix your problem long-term. However it looks like an upgrade to a v4.17.0 of docker for mac has meant docker has moved away from using this global .sock file

@LenaWil
Copy link
Author

LenaWil commented Mar 2, 2023

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

That worked, thanks!

@mingrammer
Copy link

Thank you @culshaw.

@pvmtriet232
Copy link

I got into the problem too. I use ubuntu, how can I solve it?

@bernardoforcillo
Copy link

I got into the problem too. I use ubuntu, how can I solve it?

So do I (fedora)

@kintel
Copy link

kintel commented Apr 19, 2023

I also have this failure on Ubuntu-22.04:

$ docker --version
Docker version 23.0.2, build 569dd73
gh act -v
DEBU[0000] Loading environment from /home/kintel/code/OpenGL/offscreen/.env 
DEBU[0000] Loading action inputs from /home/kintel/code/OpenGL/offscreen/.input 
DEBU[0000] Loading secrets from /home/kintel/code/OpenGL/offscreen/.secrets 
DEBU[0000] Evaluated matrix inclusions: map[]           
DEBU[0000] Loading workflows from '/home/kintel/code/OpenGL/offscreen/.github/workflows' 
DEBU[0000] Loading workflows recursively                
DEBU[0000] Found workflow 'cmake.yml' in '/home/kintel/code/OpenGL/offscreen/.github/workflows/cmake.yml' 
DEBU[0000] Reading workflow '/home/kintel/code/OpenGL/offscreen/.github/workflows/cmake.yml' 
DEBU[0000] Conditional GET for notices etag=f82d34a0-80c7-4533-902c-b80db8d0947f 
DEBU[0000] Preparing plan with all jobs                 
DEBU[0000] Using default workflow event: push           
DEBU[0000] Planning jobs for event: push                
DEBU[0000] Final matrix after applying user inclusions '[map[]]' 
DEBU[0000] Loading revision from git directory          
DEBU[0000] Found revision: 7eff393d11d435b16ddc48cbdd643a7bfdab2e74 
DEBU[0000] HEAD points to '7eff393d11d435b16ddc48cbdd643a7bfdab2e74' 
DEBU[0000] using github ref: refs/heads/master          
DEBU[0000] Found revision: 7eff393d11d435b16ddc48cbdd643a7bfdab2e74 
ERRO[0000] failed to obtain container engine info: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info": dial unix /var/run/docker.sock: connect: permission denied 
[CMake/build] [DEBUG] evaluating expression 'success()'
[CMake/build] [DEBUG] expression 'success()' evaluated to 'true'
[CMake/build] 🚀  Start image=catthehacker/ubuntu:act-latest
[CMake/build]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
[CMake/build] [DEBUG]   🐳  docker pull catthehacker/ubuntu:act-latest
[CMake/build] [DEBUG] pulling image 'docker.io/catthehacker/ubuntu:act-latest' ()
Error: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/create?fromImage=catthehacker%2Fubuntu&tag=act-latest": dial unix /var/run/docker.sock: connect: permission denied

The user running this is added to the docker group and can run docker commands without sudo.

@catthehacker
Copy link
Member

Original issue was regarding Docker on macOS, if you have similar problem on non macOS platform, create new issue and attach required info.

@kintel
Copy link

kintel commented Apr 19, 2023

See #1744

@LenaWil
Copy link
Author

LenaWil commented Apr 19, 2023

Original issue was regarding Docker on macOS, if you have similar problem on non macOS platform, create new issue and attach required info.

Why was this closed? Last time I tested I still had the issue.

I can use the work around, but for some reason I have to do that on every boot.

@jpdrsn
Copy link

jpdrsn commented Apr 21, 2023

Using rancher desktop and getting the same issue. Solution was similar to @LenaWil suggestion: sudo ln -s ~/.rd/docker.sock /var/run/docker.sock

@gentildpinto
Copy link

I don't think this is necessarily an act specific problem, but I've got around this by doing the following:

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

This isn't guaranteed to fix your problem long-term. However it looks like an upgrade to a v4.17.0 of docker for mac has meant docker has moved away from using this global .sock file

I've docker desktop on my Fedora, so I do sudo ln -s ~/.docker/desktop/docker.sock /var/run/docker.sock. And it works
Thanks ❤️

@palerdot
Copy link

I'm using colima and following works

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

@jakeseg
Copy link

jakeseg commented Nov 8, 2024

I can not run build docker images on my local worflows anymore.
I followed instrctions from:
docker/actions-toolkit#250 (comment)
#2239

Inside the workflow I was not able to connect to the docker.socket but after creating the simlink (sudo ln -s ~/.colima/default/docker.sock /var/run/docker.sock) and using --container-daemon-socket=unix:///var/run/docker.sock it said Permision denied.

I'm little dissapointed dact stoped working, I have no clue how to fix it. I know the issue is related to a docker change and mac OS update.

@jeiksegovia
Copy link

solved the issue on my machine 🥹 #2239 (comment)

@Sandwich1699975
Copy link

For those still having the issue. Check the following

  • Docker is running (Docker desktop if you are on mac)
  • There exists the symbolic link /var/run/docker.sock and that it points to another file that should exist in ~/.docker/run/docker.sock
    • If this file does not exist, go into Docker settings > Advanced > "Allow the default docker socket to be used" and make sure it is ticked. If it was already ticked, untick it and tick it again (this made the file for me)
  • Then also check that ~/.actrc does not override the container socket path to - or an invalid location with the --container-daemon-socket argument. (this was my issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.