catthehacker / docker_images

Docker images
MIT License
212 stars 75 forks source link

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. #114

Closed maaroen closed 10 months ago

maaroen commented 11 months ago

Hello,

I'm trying to use this image in a gitea act runner as image to build a docker container with. But if I start this image with for example the following command: docker run --rm -it ghcr.io/catthehacker/ubuntu:act-latest, I'm getting this error message, if I run docker ps for example: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Only if I pass the docker.sock as a volume to the container, I can get a valid result, but I'm not sure if that's what I'm supposed to do.

Could someone tell me what is exactly needed to use docker from inside this image?

Jordanb716 commented 10 months ago

I'm pretty sure this is a Gitea act_runner issue, not a problem with the image, but I just fixed this myself. You want to set DOCKER_HOST to unix:///run/user/1000/docker.sock, not unix:///var/run/docker.sock.

Also make sure to comment out the DOCKER_CERT_PATH and DOCKER_TLS_VERIFY if you have those set from the example config, or that'll cause another issue (it seems to try to TLS verify the internal address, then complain when that obviously doesn't work.)

maaroen commented 10 months ago

Hello @Jordanb716,

Do you then mean the DOCKER_HOST set on the rootless dind runner itself?

Jordanb716 commented 10 months ago

Yes, either that or the docker_host line in the runner config file. (The environment variable seems to override the config file setting, so whichever you're already using I suppose.)

Jordanb716 commented 10 months ago

Just realized I was being stupid, your setup is obviously different than mine so my solution won't work for you, sorry about that.

catthehacker commented 10 months ago

https://shisho.dev/blog/posts/docker-in-docker/