Lesstep
Bitbucket Cloud · Pipelines · Checked November 2, 2026

Bitbucket Pipelines: "Cannot connect to the Docker daemon"

A Pipelines step has a Docker daemon only when the step asks for one. When it is missing, or a tool looks for it in the wrong place, the Docker client stops with one of these:

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

The first usually means the step has no Docker daemon, or a tool went straight to the socket file. The second is the one Atlassian documents for Linux Shell runners.

The step has no docker service

Atlassian's page Run Docker commands in Bitbucket Pipelines says to add docker as a service on the step, which mounts the Docker CLI into the build container and gives the step a Docker daemon:

pipelines:
  default:
    - step:
        script:
          - docker version
          - docker build -t my-app .
        services:
          - docker

If the image has no Docker client of its own, a step without the service fails earlier, with docker: command not found.

Tools that look for /var/run/docker.sock

In Pipelines the Docker client does not use the socket file. Atlassian's list of default variables has DOCKER_HOST, "Host of the step's Docker daemon", and the client follows it. A tool or library that reads DOCKER_HOST finds the daemon; one with /var/run/docker.sock written into its settings does not. Print the variable in the step to see the address, and point the tool at it.

Mounting the socket into another container, -v /var/run/docker.sock:/var/run/docker.sock, does not work on Atlassian's machines either: a volume outside the clone directory is one of the options Pipelines refuses ("authorization denied by plugin pipelines").

Testcontainers

The Testcontainers documentation for Bitbucket Pipelines asks for two things: the docker service on the step, and Ryuk, its clean-up container, turned off, because Pipelines does not allow privileged containers. It also notes that Docker may need more memory:

pipelines:
  default:
    - step:
        image: maven:3.6.1
        script:
          - export TESTCONTAINERS_RYUK_DISABLED=true
          - mvn clean install
        services:
          - docker
definitions:
  services:
    docker:
      memory: 2048

The variable can also be a repository variable instead of the export line.

Linux Shell runners: tcp://localhost:2375

On a self-hosted Linux Shell runner, the step runs on the machine itself, and Atlassian's article "Cannot connect to Docker daemon" error while running Docker commands explains the second message: Docker works in the machine's own terminal, but the build looks for tcp://localhost:2375, which Docker does not open by default. The article adds a systemd override so dockerd also listens there, then reloads and restarts Docker:

# /etc/systemd/system/docker.service.d/options.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H unix:// -H tcp://127.0.0.1:2375
sudo systemctl daemon-reload
sudo systemctl restart docker

For an encrypted connection the article uses port 2376 with TLS certificates instead.

Runtime v3

With Runtime v3, Pipelines still provides the daemon through the docker service but no longer mounts the Docker CLI (Enable and use Runtime v3). The build image has to bring the client, or the script installs it.

Bitbucket Pipelines in IntelliJ IDEA

Pipeline Inbox for Bitbucket Pipelines, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the pipelines of all your Bitbucket Cloud repositories in an IDE tool window, with their steps, the failed step and the command it stopped at, and the step's log as Bitbucket writes it. The list, steps and logs are free; running, re-running and stopping pipelines are Pro (US$1.50 a month, with a 30-day trial).

Get it on JetBrains Marketplace

Atlassian, Bitbucket and Bitbucket Pipelines are trademarks of Atlassian; Docker is a trademark of Docker, Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Atlassian, Docker or JetBrains.

More: "authorization denied by plugin pipelines" (Docker) · "Container 'docker' exceeded memory limit." · Pipelines did not run after a push · "Container 'Build' exceeded memory limit." · "Exceeded build time limit of 120 minutes" · The cache is not used · "unexpected system error" · "command not found" · Submodules not cloned · "We couldn't clone the repository" · "No online runner available" · "No space left on device" · "Step exceeded processing limits" · The artifact is missing in the next step · The build passed before and fails now · Build setup takes too long · "You've run out of build minutes" · "Permission denied to update branch" · "You have reached your pull rate limit" (Docker Hub) · "There is an error in your bitbucket-pipelines.yml" · "This pipeline was paused" (deployments) · "Host key verification failed" (SSH) · A variable is empty · Bitbucket Pipelines plugins for IntelliJ IDEA, compared · 日本語