Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Self hosted Bitbucket pipeline fails to run docker commands

Jan Martin
July 23, 2026

We have a self-hosted Windows pipeline.

We are trying to run docker commands, e.g. docker build .

When we attempt to run this same command from terminal it works, but the pipeline runner instead gets this error:

 

+ docker build .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
Install the buildx component to build images with BuildKit:
error during connect: Post "http://localhost:2375/v1.54/build?dockerfile=myproject%2FDockerfile&t=myproject.azurecr.io%2Fmyproject&version=1": dial tcp [::1]:2375: connectex: No connection could be made because the target machine actively refused it.

2 answers

0 votes
Arkadiusz Wroblewski
Community Champion
July 24, 2026

Hello @Jan Martin 

First - Exposing 2375 - is Bananas. @Viswanathan Ramachandran 

This error happens because Bitbucket Pipelines automatically injects a `DOCKER_HOST` variable, forcing Docker to look for a TCP connection on port 2375 instead of using the standard Windows named pipe.

Clear the variable at the start of your PowerShell script step using `$Env:DOCKER_HOST = ""` or set it explicitly to `"npipe:////./pipe/docker_engine"`. Avoid enabling TCP port 2375 in Docker Desktop as that creates an unnecessary security risk. If clearing the variable results in a permission error, run `whoami` in the step to verify that the Windows service account running your runner actually has access to Docker.

Here some reference from ancient Topic

https://community.atlassian.com/forums/Bitbucket-questions/Unable-to-build-push-Windows-container-via-Windows-Runner/qaq-p/2189404 

Best,

Arek 🤠

Viswanathan Ramachandran
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 24, 2026

Hi @Arkadiusz Wroblewski 

My bad. I agree completely. I should have been more clearer. I'll just try to rule out the error and then remove again. Thank you for the mention and pointing out the reference article 

 

Like Arkadiusz Wroblewski likes this
Arkadiusz Wroblewski
Community Champion
July 24, 2026

All fine. I just wanna point that Exposing ports is never good idea image.png

0 votes
Viswanathan Ramachandran
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 23, 2026

hi @Jan Martin 

The issue looks like a protocol/port mismatch between the Bitbucket Runner and Docker.  Can you try one of these approaches:

Option A: Switch to Windows Named Pipes

You can explicitly force the runner to use the Windows Named Pipe by setting the DOCKER_HOST environment variable in your bitbucket-pipelines.yml

Option B : Enable TCP 2375 on Docker Daemon (not recommended)

alternatively, just checking, I hope your permissions are alright and set correctly? 

May be you run the Bitbucket Runner service as the same user running Docker Desktop, or try switching to Docker Engine Service.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events