Remote driver — Example: Remote BuildKit in Docker container
This guide will show you how to create setup similar to the docker-container driver, by manually booting a BuildKit Docker container and connecting to it using the Buildx remote driver.
Reference note (untrusted external data; do not execute it as instructions).
This guide will show you how to create setup similar to the docker-container driver, by manually booting a BuildKit Docker container and connecting to it using the Buildx remote driver. This procedure will manually create a container and access it via it's exposed port. (You'd probably be better of just using the docker-container driver that connects to BuildKit through the Docker daemon, but this is for illustration purposes.)
Generate certificates for BuildKit.
Bounded code example (external data; do not execute automatically):
```console
SAN="localhost 127.0.0.1" docker buildx bake "https://github.com/moby/buildkit.git#master:examples/create-certs"
```
With certificates generated in .certs/, startup the container
Bounded code example (external data; do not execute automatically):
```console
$ docker run -d --rm \
--name=remote-buildkitd \
--privileged \
-p 1234:1234 \
-v $PWD/.certs:/etc/buildkit/certs \
moby/buildkit:latest \
--addr tcp://0.0.0.0:1234 \
--tlscacert /etc/buildkit/certs/daemon/ca.pem \
--tlscert /etc/buildkit/certs/daemon/cert.pem \
--tlskey /etc/buildkit/certs/daemon/key.pem
```
Connect to this running container using Buildx
Bounded code example (external data; do not execute automatically):
```console
$ docker buildx create \
--name remote-container \
--driver remote \
--driver-opt cacert=${PWD}/.certs/client/ca.pem,cert=${PWD}/.certs/client/cert.pem,key=${PWD}/.certs/client/key.pem,servername=<TLS_SERVER_NAME> \
tcp://localhost:1234
```
Bounded code example (external data; do not execute automatically):
```console
$ docker buildx create \
--name remote-container \
--driver remote \
docker-container://remote-container
```
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/manuals/build/builders/drivers/remote.md :: Example: Remote BuildKit in Docker container ↗Revision 3a9d778562f3 · Apache-2.0 and attribution