Your first image
pycontainer builds an OCI image layout from a Python project without a Dockerfile or a Docker daemon. It can also push that image to a registry. Building does not start your application; running an image still needs a container runtime.
The project is experimental. Start with a small application and review images and dependencies before staging packages.
1. Install
Section titled “1. Install”Use Python 3.11 or newer. Install a released version:
pip install pycontainer-build# Or use an isolated CLI tool environmentuv tool install pycontainer-buildpycontainer --helpTo try the repository examples below, also get a source checkout. For an editable source install instead of a release:
git clone https://github.com/spboyer/pycontainer-build.gitcd pycontainer-buildpython -m pip install --no-deps -e .pycontainer --helpFor contributor tooling, use
uv sync --locked --group test --group build instead. If you do not activate that
environment, prefix commands with uv run --locked --group test --group build.
2. Preview the example
Section titled “2. Preview the example”The repository includes a FastAPI application. Preview its configuration without pulling a base image or building layers:
pycontainer build --context examples/fastapi-app --tag demo:local --dry-runFor your own project, run pycontainer init --template fastapi --app main:app
from its directory. The template writes configuration, not application code.
See configuration templates for Flask and generic projects.
3. Build an OCI layout
Section titled “3. Build an OCI layout”pycontainer build --context examples/fastapi-app --tag demo:local --base-image python:3.11-slim-bookworm --include-depsThis pulls the base image and stages the example’s dependencies. It needs network access and pip in the builder’s Python environment. Wheel-only staging is not cross-compilation; unsupported packages fail rather than falling back to source builds.
The output is under the build context: examples/fastapi-app/dist/image/.
It contains oci-layout, index.json, content-addressed blobs and tag references.
It is not a Docker archive.
4. Validate and run
Section titled “4. Validate and run”Inspect the output offline:
pycontainer validate image --output examples/fastapi-app/dist/imageValidation checks OCI structure and image metadata. It does not prove that the application starts.
With Skopeo installed and a running Docker daemon, import the layout and run it:
skopeo copy oci:examples/fastapi-app/dist/image docker-daemon:demo:localdocker run --rm -p 8000:8000 demo:localOpen http://localhost:8000. Docker is used here to run the result, not to build it.
For further local workflows, see local development.
5. Publish when ready
Section titled “5. Publish when ready”Use a registry repository you can write to:
pycontainer build --context examples/fastapi-app --tag ghcr.io/YOUR_USER/demo:latest --base-image python:3.11-slim-bookworm --include-deps --pushDo not put credentials in commands, configuration files or image layers. Follow registry authentication and publication for host-scoped authentication and transport rules.
Where next?
Section titled “Where next?”- Configuration: CLI settings, TOML, dependencies and cache.
- Image validation: exact checks and coverage limits.
- Deployment artifacts: generate Kubernetes, Helm or Compose files.
- Skaffold and Tilt: registry-based development loops.