Skip to content

Docker in docker no longer works in summerwind/actions-runner-dind-rootless, docker socket not properly shared #2548

Open

Description

@m-barczyk

Checks

Controller Version

0.27.3

Helm Chart Version

0.23.2

CertManager Version

N/A

Deployment Method

Helm

cert-manager installation

N/A

Checks

  • This isn't a question or user support case (For Q&A and community support, go to Discussions. It might also be a good idea to contract with any of contributors and maintainers if your business is so critical and therefore you need priority support
  • I've read releasenotes before submitting this issue and I'm sure it's not due to any recently-introduced backward-incompatible changes
  • My actions-runner-controller version (v0.x.y) does support the feature
  • I've already upgraded ARC (including the CRDs, see charts/actions-runner-controller/docs/UPGRADING.md for details) to the latest and it didn't fix the issue
  • I've migrated to the workflow job webhook event (if you using webhook driven scaling)

Resource Definitions

apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: runner-<hidden>-test
  namespace: actions-runners-dev
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: "<hidden>-controller-dev-runner"
    spec:
      ephemeral: true
      dockerdWithinRunnerContainer: true
      repository: <hidden>/<hidden>
      image: summerwind/actions-runner-dind-rootless:ubuntu-22.04
      labels:
        - <mylabel>

To Reproduce

1. Run workflow based on `actions-runner-dind-rootless` which uses docker inside container, as an example:

jobs:
  test-runner-in-container:
    runs-on: [ self-hosted, <hidden> ]
    container:
      image: docker:23.0
    steps:
      - name: check out repository code
        uses: actions/checkout@v3
      - name: test docker inside container
        run: |
          docker ps
  1. docker ps will fail because /var/run/docker.sock is not a docker socket.

Describe the bug

Docker containers started in the runner don't have a working docker:

runner@runner-myorg-test-q56m5-sq49m:~$ docker ps
CONTAINER ID   IMAGE         COMMAND               CREATED          STATUS          PORTS           NAMES
ea6daf34cb62   docker:23.0   "tail -f /dev/null"   12 minutes ago   Up 12 minutes   2375-2376/tcp   945bfd4a364f443989b9c74270e20b29_docker230_e5a62a

runner@runner-myorg-test-q56m5-sq49m:~$ docker exec -it ea6daf34cb62 sh

/__w/<hidden>/ # docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

It is because docker.sock is not shared properly between the runner and containers. On the runner DOCKER_HOST is:

runner@runner-myorg-test-q56m5-sq49m:~$ echo $DOCKER_HOST
unix:///run/user/1000/docker.sock

But runner is trying to share /var/run/docker.sock with the container:

runner@runner-myorg-test-q56m5-sq49m:~$ docker inspect ea6daf34cb62
            {
                "Type": "bind",
                "Source": "/var/run/docker.sock",
                "Destination": "/var/run/docker.sock",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },

/var/run/docker.sock does not exist on actions-runner-dind-rootless runners. /run/user/1000/docker.sock should be a Source of the above bind.

Describe the expected behavior

I would like docker to work inside containers started by the runner when using actions-runner-dind-rootless.

Whole Controller Logs

N/A

Whole Runner Pod Logs

N/A

Additional Context

N/A

Activity

  1. added
    bug
    needs triage
    on Apr 28, 2023
  2. ViniciusBastosTR commented on May 8, 2023

    @ViniciusBastosTR

    Same issue here.

  3. m-barczyk commented on May 15, 2023

    @m-barczyk
    Author

    Hi. The same for me. Just wandering if this issue is fixed by this PR: #2536?

    Nope. In case of the rootless runner the socket is completely in a different place /run/user/1000/docker.sock.

  4. nascit commented on May 23, 2023

    @nascit

    having the same issue

  5. sjjamsa commented on May 24, 2023

    @sjjamsa

    Having this issue with rootless podman in a self-hosted runner.

    Workaround currently to symlink /var/run/docker.sock --> /run/user/1000/podman/podman.sock but, this would not work out if we had more than one user on the machine.

  6. enricojonas commented on Jun 9, 2023

    @enricojonas

    Same issue for me with latest release 0.27.4 / helm chart 0.23.3

    permission denied while trying to connect to the Docker daemon socket at unix:///run/docker.sock: Get "http://%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix /run/docker.sock: connect: permission denied

  7. dduzgun-security commented on Jun 12, 2023

    @dduzgun-security

    I have the same problem here using ghcr.io/actions-runner-controller/actions-runner-controller/actions-runner-dind-rootless:v2.304.0-ubuntu-22.04-34fdbf1. Even with the privileged=true securityContext.

    permission denied while trying to connect to the Docker daemon socket at unix:///run/user/1000/docker.sock: Get "http://%2Frun%2Fuser%2F1000%2Fdocker.sock/v1.24/containers/json": dial unix /run/user/1000/docker.sock: connect: permission denied

  8. noamgreen commented on Jun 28, 2023

    @noamgreen

    any news ? same issues
    Controller Version
    0.27.4

  9. enricojonas commented on Jul 25, 2023

    @enricojonas

    Any update? We are stuck on the old release. Can we work around this problem in some other way if the original change that "broke" this cannot be undone?

  10. m-barczyk commented on Jul 25, 2023

    @m-barczyk
    Author

    Any update? We are stuck on the old release. Can we work around this problem in some other way if the original change that "broke" this cannot be undone?

    The workaround we use to overcome this problem is to build our own image based on actions-runner-dind-rootless in which we create this link in the base runner:

    ln -s /run/user/1000/docker.sock /var/run/docker.sock
    
  11. enricojonas commented on Jul 26, 2023

    @enricojonas

    I think my problem is different. We are using docker:dind image as sidecar. When I compare a runner from the latest release vs. a runner from the old release I can see difference in DOCKER_HOST variable:

    working runner on old release show following in pod definition:

    - name: DOCKER_HOST
      value: tcp://localhost:2376
    

    new version shows following in pod definition:

    - name: DOCKER_HOST
      value: unix:///run/docker.sock
    

    I guess this brakes it as it should connect to the sidecar and not the docker daemon in the container itself.

    I tried to update the runner template to override the DOCKER_HOST with the working value but it was for some reason not working, still pointing to unix:///run/docker.sock

    It seems runner_controller.go overwrites this!?

    Old version:

    		runnerContainer.Env = append(runnerContainer.Env, []corev1.EnvVar{
    			{
    				Name:  "DOCKER_HOST",
    				Value: "tcp://localhost:2376",
    			},
    

    New version:

    		runnerContainer.Env = append(runnerContainer.Env,
    			corev1.EnvVar{
    				Name:  "DOCKER_HOST",
    				Value: "unix:///run/docker.sock",
    			},
    		)
    
  12. piotrgo commented on Aug 29, 2023

    @piotrgo

    What Kubernetes version are you running? Is it because 1.24 dropped support for docker?

  13. enricojonas commented on Aug 29, 2023

    @enricojonas

    @piotrgo we are running 1.26.5-gke.1400 in this particular case but I don't think it's because any docker support was dropped from GKE side as it still works with the old ARC version. I haven't tried the latest version yet but just hovering over the changelog doesn't reveal anything that might have fixed this issue.

  14. m-barczyk commented on Aug 29, 2023

    @m-barczyk
    Author

    @enricojonas try this solution: #2548 (comment)

  15. sbalasu27 commented on Oct 21, 2023

    @sbalasu27

    I'm posting this on behalf of @enricojonas , we are using our own runner image and adding the docker group with gid 1001 to the user solves the issue for us.

  16. foood commented on Mar 7, 2024

    @foood

    Had the same issue, there is workaround, since actions container support custom volume mounts.
    example:

    jobs:
      test-runner-in-container:
        runs-on: [ self-hosted, <hidden> ]
        container:
          image: docker:23.0
          volumes:
            - /run/docker/docker.sock:/run/docker/docker.sock
          env:
            DOCKER_HOST: unix:///run/docker/docker.sock
        steps:
          - name: check out repository code
            uses: actions/checkout@v3
          - name: test docker inside container
            run: |
              docker ps
    
  17. necipakca commented on Jan 2, 2025

    @necipakca

    Just set the env DOCKER_HOST=unix:///run/user/1000/docker.sock, then everything should be fine!

  18. Steed-LHV commented on Feb 18, 2025

    @Steed-LHV

    Just set the env DOCKER_HOST=unix:///run/user/1000/docker.sock, then everything should be fine!

    @necipakca hi, set the env like this
    env: - name: DOCKER_HOST value: unix:///run/user/1000/docker.sock

    but still got the error
    runner Cannot connect to the Docker daemon at unix:///run/user/1000/docker.sock. Is the docker daemon running?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions