Skip to main content

Easy-to-use wrapper for multi-platform Docker image builds.

Project description

mdocker

An easy-to-use wrapper for multi-platform Docker image builds.

Contents

Description

mdocker is a simple wrapper over Docker Buildx, which can be used for convenient image builds targeted for multiple platforms.

This tool was originally designed as a workaround to a limitation that Buildx has with the --load parameter.

[!NOTE] There are, however, some workarounds and progress towards this issue.

The amount of target platforms specified for this wrapper is equal to the amount of tags generated in local cache.

E.g., if linux/arm64 and linux/amd64 were specified as target platforms for the demo image, you will get demo:arm64 and demo:amd64 built and stored within your local Docker cache.

Usage

mdocker requires an installation of Python 3.10+.

Below is a help message with the description of arguments.

$ python3 -m mdocker --help
usage: [-h] [--context BCONTEXT] [--file DFILE] [--platforms PLATFORMS] [--push] name

positional arguments:
  name                  specify a name for the image

options:
  -h, --help            show this help message and exit
  --context BCONTEXT    specify a path to build context
  --file DFILE          specify a path to Dockerfile
  --platforms PLATFORMS
                        specify target platforms (e.g., --platforms linux/amd64,linux/arm64)
  --push                push image to remote registry

Package Compatibility

In some cases, packages for Docker images may not be available across all target platforms. E.g., a package "some_package" may be available for amd64, but may not be available for arm64 platform.

Is cases like this, you can define custom installation rules within your Dockerfile itself.

An example of such custom rule usage can be found here.

Docker's default back-end (BuildKit) provides built-in variables that can be used for determining target platform set for the current build.

The full list of these variables can be found here.

Examples

You can try out mdocker with it's own Dockerfile!

The command below will build the demo image for both amd64 and arm64 target architectures:

python3 -m mdocker demo --platforms linux/amd64,linux/arm64

Optionally, you can specify paths to the build context and Dockerfile:

python3 -m mdocker demo --context . --file ./Dockerfile --platforms linux/amd64,linux/arm64

Installation

From PyPI (recommended)

To install latest mdocker package from PyPI, use:

python3 -m pip install mdocker

Local from source

To install and debug mdocker locally, in the root of repository use:

python3 -m pip install -e .

No installation, direct run from source

To run mdocker without any installation into local cache, in the root of repository use:

export PYTHONPATH=$(pwd)
python3 -m poetry install --no-root
python3 mdocker <arguments>

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdocker-0.3.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

mdocker-0.3.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file mdocker-0.3.1.tar.gz.

File metadata

  • Download URL: mdocker-0.3.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.3

File hashes

Hashes for mdocker-0.3.1.tar.gz
Algorithm Hash digest
SHA256 bfb17b991134cd70a01a385f6df4025a245679703dfc3b6deee5d452c7ae7892
MD5 b49e61523f370c4738fae1413f9b7fa8
BLAKE2b-256 35f1a5253dd745e8052f539a599f0dc58d0d3b3df0cb5128f29f237b52b0883c

See more details on using hashes here.

File details

Details for the file mdocker-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: mdocker-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.3

File hashes

Hashes for mdocker-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 df9c405e0fe98f8a0dd198fa538b30331adcb5727af95c8952dde8c685d21e83
MD5 eeba6a31c19f6d9ab6c65bac38d9fe0f
BLAKE2b-256 ee35445bcb40171ec95e4d406172d8c8fd53147b5dcbe2693729e1f52d60f786

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page