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.
Running results
Docker log shows the dind is running
The pipeline still calls the built-in docker CLI
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
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.