Docker Community Forums

Share and learn in the Docker community.

Buildx inside dind docker

HI

I am trying to build a multiarc docker image.

Therfore I have run an dind docker 19-03.

docker run --privileged --network bennis-runner-net --name dind --network-alias docker \
 -e DOCKER_DRIVER=overlay2 -e DOCKER_TLS_CERTDIR=/certs -v $(pwd)/certs:/certs docker:19.03.5-dind --experimental

Then I build my own docker which is just a docker:19:03

FROM docker:19.03.5

RUN mkdir -p /etc/docker && echo ‘{“experimental”: true}’ > /etc/docker/daemon.json

RUN mkdir -p ~/.docker/cli-plugins &&
wget -O ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.3.1/buildx-v0.3.1.linux-amd64 &&
chmod a+x ~/.docker/cli-plugins/docker-buildx && \

VOLUME /var/lib/docker
EXPOSE 2375 2376

then run

docker run -it --network bennis-runner-net --privileged -e DOCKER_HOST=tcp://docker:2376 -e DOCKER_TLS_VERIFY=1 -v /var/run/docker.sock:/var/run/docker.sock
-e DOCKER_CERT_PATH=/certs/client -v (pwd)/../certs/client:/certs/client -v (pwd)/qemu-arm-static:/usr/local/bin/qemu-arm-static -e DOCKER_CLI_EXPERIMENTAL=enabled owndocker /bin/sh

I got buildx up and running inside my dind docker , but i can just use the driver docker

I want to use the driver docker-container. I have tried to enable the qemu–user-static and binfmt-support. I have tried to get it work but i just cant get it work.

When I want to create

docker buildx create --driver docker-container --name mybuilder

i get the following message

could not create a builder instance with TLS data loaded from environment. Please use `docker context create <context-name>` to create a context for current environment and then create a builder instance with `docker buildx create <context-name>`

So it cant use the binfmt. On my host system with the normal docker deamon it works fine. I got the arm support running.

Anyone an idea how to get it work?

Hi, I also had this issue, maybe some change could help your build environment:

DOCKER_TLS_CERTDIR=""
instead of
DOCKER_TLS_CERTDIR=/certs

docker:19.03.0-dind
instead of
docker:19.03.5-dind

DOCKER_HOST=tcp://docker:2375
instead of
DOCKER_HOST=tcp://docker:2376

Following URL are very helpfully for this issue:

Cheers