Installing buildx on moby

What is a Docker Plugin?

A Docker plugin is an executable that follows the docker-{plugin_name} naming convention. It can be
placed in the ~/.docker/plugins directory for the current user or in one of the following global directories:

  • /usr/local/lib/docker/cli-plugins
  • /usr/local/libexec/docker/cli-plugins
  • /usr/lib/docker/cli-plugins
  • /usr/libexec/docker/cli-plugins

Why do I need Buildx?

The primary reason for using the Buildx plugin is to enable multi-platform builds and parallel building
of multiple targets with the bake command. You can find more information about bake here.

What’s up with Moby?

Moby is the open-source base project of Docker. While it is not recommended as a developer tool, it is
more suitable for tinkering with Docker internals. Despite that it’s the tool of my choice since it is easier to adopt on Fedora
compared to Docker CE. This is mainly because some upcoming fixes, designed to address updates more promptly, are implemented in Moby
first. Fedora aims to provide the latest Linux packages faster than other distributions. The only drawback I have
observed so far is that all plugins are disabled by default in Moby, unlike Docker CE.

How to install Buildx

  1. Download the Buildx binary into your user’s Docker plugins directory (Alternatively, you can download
    it to one of the global directories mentioned above):

    1
    2
    wget https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-amd64 \
    -O ~/.docker/cli-plugins/docker-buildx
  2. Make it executable :

    1
    chmod +x ~/.docker/cli-plugins/docker-buildx
  3. Check that the plugin is enabled:

    1
    docker info

First build

  1. Create builder:

    1
    docker buildx create --name multiarch --driver docker-container --use
  2. Login to your registry in my case ECR:

    1
    2
    3
    $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email 2> /dev/null) || aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login \
    --username AWS \
    --password-stdin $AWS_ACC.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
  3. Build and push to repo. Remember that multi-architecture build make sense only for pushing to a repository. Then when you pull the image back the one applicable to your host machine will be pulled.

    1
    docker buildx build --platform linux/amd64,linux/arm64 --push -t "$AWS_ACC.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$REPO:$TAG" -
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2012-2023 Andreas Galazis

请我喝杯咖啡吧~