DevZero Logo
DevZero

Docker

Setting up a Docker remote build cache on DevZero.

Remote build/cache using DOCKER_HOST

  1. Create a new workspace with Docker installed (How-to).
  2. Make sure you are connected to the DevZero network:
dz net connect
  1. Set DOCKER_HOST environment variable on your machine to match the DevBox hostname:
export DOCKER_HOST=ssh://devzero@your-devbox-hostname
  1. Verify the installation by running:
docker info

When you run the docker build command, the build context will be sent to the DevBox and the build process will run.

If you're seeing "Host key verification failed" error, try connecting to your DevBox via ssh first to verify the fingerprint.

Remote build using BuildKit

  1. Create a new workspace with Docker installed (How-to).
  2. Inside your DevBox, run the BuildKit container:
docker run -d --rm --name=remote-buildkitd --privileged -p 1234:1234 moby/buildkit:latest --addr tcp://0.0.0.0:1234

See Remote driver docs for all available options.

  1. On your machine, create a new buildx instance:
docker buildx create --name remote-container --driver remote tcp://your-devbox-hostname:1234
  1. Build an image using remote driver (and download it locally):
docker buildx build --builder=remote-container -t test --load .

Remote cache using Docker Registry

  1. Create a new workspace with Docker installed (How-to).
  2. Inside your DevBox, install the Docker Registry:
docker run -d -p 5000:5000 --name registry registry:2

See CNCF Distribution guide for available options.

  1. Make sure your machine is connected to the DevZero network:
dz net connect
  1. Verify you can access the registry from your machine:
curl http://your-devbox-hostname:5000/v2/_catalog
  1. Build and push your image to the registry

With Docker:

docker build --push -t your-devbox-hostname:5000/<image> .

With BuildKit remote cache (see previous section):

docker buildx build --push -t your-devbox-hostname:5000/<image> \
  --cache-to type=registry,ref=your-devbox-hostname:5000/<cache-image> \
  --cache-from type=registry,ref=your-devbox-hostname:5000/<cache-image>
  1. Verify the image is available in the registry:\
curl http://your-devbox-hostname:5000/v2/_catalog

If you're getting "http: server gave HTTP response to HTTPS client", try adding the following to your Docker daemon json configuration:

insecure-registries": ["your-devbox-hostname:5000"]

On this page