Skip to main content

Generate multiple docker cointainers to test projects

Project description

Container-tester

container_small

Overview

Container-Tester is a small Python utility that helps you test your project on top of many different Linux distributions without having to run and maintain lots of Docker tests yourself. It provides a command-line interface (CLI) that can:

  • Build that Dockerfile into a image and report its size and metadata.
  • Run a container from that image, execute a command inside it and capture the logs.
  • Optionally clean up images and containers when you are done.
  • Iterate over a curated list of popular Python, Debian/Ubuntu, Fedora and Alpine base images defined in docker-config.toml and perform the above steps for each of them.

Installation

You can use Container-Tester in two ways:

  1. Install in your project:

    uv add container-tester
    uv run contest --help
    
    # or if you don't want to install:
    uvx --from container-tester contest --help
    

Using Container-tester

Usage: contest [OPTIONS] [OS_NAME]

Generate, build, and run Docker resources from a base image or config file.

+- Options -------------------------------------------------------------------+
| --json    --no-json          Show output in json format                     |
|                              (use --json to enable) [default: no-json]      |
| --pretty  --no-pretty        Show output in pretty format                   |
|                              (use --pretty to enable) [default: no-pretty]  |
| --clean   --no-clean         Clean Docker resources after run               |
|                              (use --clean to enable) [default: no-clean]    |
| --install-completion         Install completion for the current shell.      |
| --show-completion            Show completion for the current shell, to copy |
|                              it or customize the installation.              |
| --help                       Show this message and exit.                    |
+-----------------------------------------------------------------------------+

+- Commands ------------------------------------------------------------------+
| test-config     Generate, build, and run Docker resources from a docker     |
| test-container  Generate, build, and run Docker resources from a base image.|
+-----------------------------------------------------------------------------+

Example

Here is a quick example that runs a simple command across all default profiles:

uv run contest test-config

To test only on the Ubuntu image, you can specify its base image directly and use a custom command:

uv run contest test-container ubuntu:latest --command "echo Hello, world!"

Default profiles

By default, Container-Tester comes with a handful of profiles covering common Python, Debian/Ubuntu and Alpine base images. Each profile defines an image_tag (used as the resulting image name) and the corresponding os_name. A few of them are shown below- see src/container_tester/docker-config.toml for the full list:

image_tag os_name
py312_trixie python:3.12-slim-trixie
ubuntu_latest ubuntu:latest
alpine_latest alpine:latest

Custom Docker Configuration

You can define your own docker-config.toml file to run custom Docker images tailored to your needs. Use the following format to specify multiple profiles:

[py311_slim]
command = ""
os_name = "python:3.11-slim"
os_commands = []
pkg_manager = "apt"

[ubuntu_latest]
command = ""
os_name = "ubuntu:latest"
os_commands = ["apt-get update && apt-get install -y ca-certificates"]
pkg_manager = "apt"

# Add more profiles as needed...

Configuration Fields

  • command: Shell command to execute inside the containers.
  • image_tag: A unique identifier for the Docker image profile.
  • os_name: The name and tag of the Docker image to use.
  • os_commands: A list of shell commands to run after container startup (optional).
  • pkg_manager: The package manager used by the OS (e.g., apk, dnf, apt).

Run with Your Custom Config

After creating your docker-config.toml file, launch your custom Docker setup by running:

uv run contest test-config

License

This project is licensed under the terms of the MIT license.

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

container_tester-1.0.0rc1.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

container_tester-1.0.0rc1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file container_tester-1.0.0rc1.tar.gz.

File metadata

  • Download URL: container_tester-1.0.0rc1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for container_tester-1.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 55684cfc313cd98f987ca932e1bc2c96d502f3364dda7917c3e612e45247ceeb
MD5 70cf09161b0880f8c719ea101abee44b
BLAKE2b-256 2046eafc8522f33fd350d93d7b4a30c7e4b89c461c7885c9e747f15932bed0b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for container_tester-1.0.0rc1.tar.gz:

Publisher: publish_all.yml on geopozo/container-tester

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file container_tester-1.0.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for container_tester-1.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 578fbba74f9380ead273438072989c411bb49bf0c1fad08dd048d90cece9f206
MD5 387fc61e1ca108ba76613833b0076179
BLAKE2b-256 bd35e96efc865c773558e6591ff71511a7eb5617442a030db6733bbd79e9c7d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for container_tester-1.0.0rc1-py3-none-any.whl:

Publisher: publish_all.yml on geopozo/container-tester

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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