Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to connect to docker daemon in Bitbucket pipeline

pp I'm New Here Apr 19, 2021

I want to run a docker container in a Bitbucket pipeline. To be more explicit: I want to run a python script which builds a docker image using os.system commands. But I cannot execute any commands as it claims the docker daemon is not running. However, I did not find any way to start it.

Here are the commands I run in that python script and their output:

INFO     Running command 'which docker' in '/opt/atlassian/pipelines/agent/build'
INFO     STDOUT b'/usr/bin/docker\n'
INFO     Running command 'docker --version' in '/opt/atlassian/pipelines/agent/build'
INFO     STDOUT b'Docker version 19.03.15, build 99e3ed8\n'
INFO     Running command 'systemctl start docker' in '/opt/atlassian/pipelines/agent/build'
INFO     STDERR b'/bin/sh: 1: systemctl: not found\n'
INFO     Running command 'sudo systemctl start docker' in '/opt/atlassian/pipelines/agent/build'
INFO     STDERR b'/bin/sh: 1: sudo: not found\n'
INFO     Trying to remove old Docker container...
INFO     Running command 'docker container rm test_container' in '/opt/atlassian/pipelines/agent/build'
INFO     STDERR b'Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?\n'  
Every other command of type "docker <dosomething" will fail with the same error message.

I am using the Python3.8 docker image. This is the pipeline step:

  - step: &test-docker
      name: Build the docker container and run the tests against it
      - pip install tox
      - docker info
      - tox -e test-docker
        - docker


1 answer

Hi and welcome,

Note that if you are using a python docker image ( ). Docker itself isnt installed on that image so you can use python commands within your container but not docker commans as docker daemon isnt present on your container.


You cannot use the docker daemon bitbucket pipelines uses to run your docker image, you need to use the one that comes with your container so you may want to install docker on your container in advance or use another docker container to suit your needs.


pp I'm New Here Apr 20, 2021

Hello Jack, thank you very much for the quick answer!
So if I understood you correctly I would have to install either docker in the python-container or use the this image and install python in it.
When trying to install docker in the Dockerfile using

RUN apt-get -yqq update && apt-get -yqq install
VOLUME /var/run/docker.sock

I still got the same error when running the python script ("Cannot connect to the docker daemon...")

When I try to install python in the pipelines-docker-daemon image I get the message that "apt" and "sudo" is not available in that image.

I found out that it would work to build the docker container in the Pipeline defined with the bitbucket-pipeline.yml and to access the webservice that container is running from the python script.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

636 views 7 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you