A tool for rapidly creating containerised development environments
Project description
container-magic
Define your container workflow in a single YAML file. Container-magic generates a Dockerfile, build script, and run script that work with Docker or Podman - container-magic is not a dependency of your final product.
How It Works
You write a cm.yaml. Container-magic generates a Dockerfile, build.sh, and run.sh from it. These generated files are committed to your repository so that anyone can build and run the project with Docker or Podman.
For development, cm build and cm run read the config directly and handle workspace mounting, user identity mapping, and runtime features automatically.
Quick Start
pip install container-magic
cm init python:3.11 my-project
cd my-project
cm build
cm run python --version
A minimal cm.yaml:
names:
image: my-project
workspace: workspace
user: nonroot
stages:
base:
from: python:3.11-slim
steps:
- apt-get:
install:
- git
- build-essential
- pip:
install:
- numpy
- pandas
development:
from: base
production:
from: base
Build and run the production image:
./build.sh
./run.sh python workspace/train.py
Key Features
- Development and production from one config - live-mounted workspace in dev, baked-in code in prod
- Automatic user handling - host user identity in dev, dedicated user in prod, no manual setup
- GPU, display, and audio - NVIDIA GPU passthrough, X11/Wayland forwarding, PulseAudio/PipeWire
- Custom commands - define once, use in both dev and prod with port publishing and environment variables
- Multi-stage builds - share steps between stages, automatic virtual environments for pip
- Transparent execution - run commands from anywhere in your repo with automatic path translation
- AWS credential forwarding - mount host AWS config into the container
- Cached assets - download models and datasets once, reuse across builds
Documentation
Full documentation is available at markhedleyjones.com/container-magic.
| Page | Contents |
|---|---|
| Getting Started | Installation, first project, workflow |
| Configuration | Full YAML reference - names, runtime, stages, commands |
| Build Steps | Package managers, custom commands, layer caching |
| Cached Assets | Asset downloading, caching, and cache management |
| User Handling | Dev vs prod users, copy ownership, permissions |
| Troubleshooting | Common issues and solutions |
Contributing
Contributions and feedback welcome! Open an issue or pull request on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file container_magic-4.3.0.tar.gz.
File metadata
- Download URL: container_magic-4.3.0.tar.gz
- Upload date:
- Size: 41.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
045b529398e99ad04560b9d215feeb7b51f3a55944fef63cae12f839ce64029c
|
|
| MD5 |
221c5badc291b63aa9259a393446a1f6
|
|
| BLAKE2b-256 |
64308b26352b9408f3557219641ac9c7953deba1c3d76a1f3d86b28963938d80
|
Provenance
The following attestation bundles were made for container_magic-4.3.0.tar.gz:
Publisher:
ci.yml on markhedleyjones/container-magic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
container_magic-4.3.0.tar.gz -
Subject digest:
045b529398e99ad04560b9d215feeb7b51f3a55944fef63cae12f839ce64029c - Sigstore transparency entry: 1185305432
- Sigstore integration time:
-
Permalink:
markhedleyjones/container-magic@c2bf9a7ee44a004c5137f3235c69a0e3465f715e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/markhedleyjones
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@c2bf9a7ee44a004c5137f3235c69a0e3465f715e -
Trigger Event:
push
-
Statement type:
File details
Details for the file container_magic-4.3.0-py3-none-any.whl.
File metadata
- Download URL: container_magic-4.3.0-py3-none-any.whl
- Upload date:
- Size: 47.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdb01841df0d92ab04db27cdb7e834c902c88d9e8017be28b58bd2e179c06ba7
|
|
| MD5 |
676c63ad562836539cc7b806183ae369
|
|
| BLAKE2b-256 |
18bda06762a8ff5f394c5b37553b9c769ae13a8276f22e11d92089159ecfb83b
|
Provenance
The following attestation bundles were made for container_magic-4.3.0-py3-none-any.whl:
Publisher:
ci.yml on markhedleyjones/container-magic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
container_magic-4.3.0-py3-none-any.whl -
Subject digest:
bdb01841df0d92ab04db27cdb7e834c902c88d9e8017be28b58bd2e179c06ba7 - Sigstore transparency entry: 1185305451
- Sigstore integration time:
-
Permalink:
markhedleyjones/container-magic@c2bf9a7ee44a004c5137f3235c69a0e3465f715e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/markhedleyjones
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@c2bf9a7ee44a004c5137f3235c69a0e3465f715e -
Trigger Event:
push
-
Statement type: