Forums

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

Bitbucket Pipeline Doesn't Use the Docker-in-Docker Daemon

Huacong Cai
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 16, 2024

I am trying to use docker buildx command (used by docker compose build) and according to this KB article, it seems that I could use the custom docker-in-docker image to get the latest docker and achieve that. However, after setting up the docker image (another instructions), running docker --version still invokes the built-in docker daemon, what am I missing?

Runner version: 1.551

Bitbucket Config

It is using the custom docker name since the default name didn't work and I was trying to see if using a custom name would make the pipeline refer to the custom docker daemon.

Screenshot 2024-01-16 at 09.47.22.pngScreenshot 2024-01-16 at 09.47.34.png

 

Running results

Docker log shows the dind is running

Screenshot 2024-01-16 at 09.49.30.png

The pipeline still calls the built-in docker CLI

Screenshot 2024-01-16 at 09.49.12.png

1 answer

1 vote
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 18, 2024

G'day, @Huacong Cai 

Welcome to the community.

It appears that you are using Golang image, so I wonder if the experimental feature is enabled. Could you revisit the guide again and make sure to follow the steps to enable the Docker experimental feature as well as moved the build plugin?

below is the example YAML:

pipelines:
  default:
    - step:
        name: My Runner
        image: atlassian/default-image:4
        runs-on:
          - linux
          - self.hosted
        services:
          - docker
        script:
          - echo "Executing on self-hosted runner" 
          - export DOCKER_CLI_EXPERIMENTAL=enabled # Enable usage of buildx in Docker version < 23
          - export BUILDX_VERSION=0.11.0  # define what BUILDX_VERSION to download and install
          - curl -fsSLO https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-amd64
          - mkdir -p $HOME/.docker/cli-plugins/ && mv buildx-v${BUILDX_VERSION}.linux-amd64 $HOME/.docker/cli-plugins/docker-buildx && chmod +x ~/.docker/cli-plugins/docker-buildx # download buildx and move it to the docker plugin folder
          - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes; docker buildx create --use # setup the QEMU emulation environment
          - echo $DOCKER_HUB_PASS | docker login --username $DOCKER_HUB_USER --password-stdin # login to Dockerhub 
          - docker buildx build -t $DOCKER_HUB_USER/my_image_multi_arch:my_tag --push --platform linux/amd64,linux/arm64,linux/arm/v7 . # Build multi-architecture image for the platforms provided and push to Dockerhub
definitions:
  services:
    docker: # Define a custom docker daemon - can only be used with a self-hosted runner
      image: docker:dind

Regards,
Syahrul

Suggest an answer

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

Atlassian Community Events