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:
Every other command of type "docker <dosomething" will fail with the same error message.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'
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
script:
- pip install tox
- docker info
- tox -e test-docker
services:
- docker