Jarede
Jarede

Reputation: 3498

Trying to run dependabot CLI on the docker:dind image but it's telling me docker daemon is not running

I'm trying to run the Dependabot CLI on my Bitbucket pipeline using the docker docker:dind image. I've installed go, and Dependabot CLI seems to have happily installed too, however when it comes to running it, I receive the error message: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

My pipeline looks like this:

pipelines:
  custom:
    dependency-update:
      - step:
          name: Update dependencies
          image: docker:dind
          script:
            - export PATH=/usr/local/go/bin:$PATH
            - apk add --no-cache git make musl-dev go
            - export LOCAL_GITHUB_ACCESS_TOKEN=$BITBUCKET_PR_ACCESS_TOKEN
            - export GOROOT=/usr/lib/go
            - export GOPATH=/go
            - export PATH=/go/bin:$PATH
            - mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
            - go install github.com/dependabot/cli/cmd/dependabot@latest
            - dependabot update -f dependabot-job.yml

And when running the pipeline, I receive:

+ dependabot update -f dependabot-job.yml.

cli | 2024/08/12 11:26:29 Inserting $LOCAL_GITHUB_ACCESS_TOKEN into credentials

cli | 2024/08/12 11:26:29 pulling image: ghcr.io/github/dependabot-update-job-proxy/dependabot-update-job-proxy:latest

cli | 2024/08/12 11:26:29 updater failure: failed to pull ghcr.io/github/dependabot-update-job-proxy/dependabot-update-job-proxy:latest: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

I thought the docker in docker image would have docker running automatically, is there something else I need to do first, or is there a simpler way to run Dependabot CLI in a bitbucket pipeline?

Upvotes: 0

Views: 260

Answers (1)

Jarede
Jarede

Reputation: 3498

You don't need to run with Docker in Docker to get access to the Docker Daemon. You can enable the Docker service to be available by setting

services:
  - docker

So the pipeline becomes:

pipelines:
  custom:
    dependency-update:
      - step:
          name: Update dependencies
          image: golang:latest
          max-time: 120
          script:
            - export LOCAL_GITHUB_ACCESS_TOKEN=$REPOSITORY_OAUTH_ACCESS_TOKEN
            - export NPM_TOKEN=$NPM_TOKEN
            - go install github.com/dependabot/cli/cmd/dependabot@latest
            - dependabot update -f dependabot-job.yml
          services:
            - docker

Upvotes: 0

Related Questions