Skip to main content

Ephemerun

Incredibly temporary containers

Ephemerun wraps around an existing container system on your computer. It lets you run a single one-liner which spins up a container, does a series of things in it, and then tears it all down again afterwards.

It is a good way to run a test suite. It is particularly good at running the tests multiple times using slightly different base images (e.g. to ensure compatibility with multiple platform versions). It also has support for building artefacts in a container and downloading them out to the host system.

It is especially helpful when combined with make. There is no good way to define a teardown recipe in a Makefile, so if you spin up a container and one of your actions fails make will stop and leave your "temporary" container permanently floating around. But Ephemerun will always tidy up after itself so can be safely called from a Makefile.

Installation

This codebase is available on PyPI:

$ pip install ephemerun

but can also be installed straight from the Git source:

$ pip install git+https://github.com/pscl4rke/ephemerun.git

Example Usage

Silly demo:

$ ephemerun \
    -i python:3.9-slim-bullseye \
    -S pwd \
    -W /tmp \
    -S pwd

Real-world example of running tests:

$ ephemerun \
    -i "python:3.9-slim-bullseye" \
    -v "$(pwd):/root/src:ro" \
    -W "/root" \
    -S "cp -air ./src/* ." \
    -S "pip --no-cache-dir install .[testing]" \
    -S "mypy --cache-dir /dev/null projectdir" \
    -S "coverage run -m unittest discover tests/" \
    -S "coverage report -m"

Real-world example of building an artefact:

$ ephemerun \
    -i "docker.io/library/golang:1.23" \
    -v "$(pwd):/root/src:ro" \
    -W "/root" \
    -S "cp -air ./src/* ." \
    -S "go build hello.go" \
    -D hello
$ ./hello

Quick Docs

  • Use -i to set the base image for the temporary container.
  • Use -v to mount a directory into it (where the :ro suffix makes it readonly).
  • Run -W to change the current working directory.
  • Run -S to execute a line in a shell.
  • Run -D to download a file out of the container (with a :destname suffix if you want a different name).
  • And of course -h gives you usage info!

Roadmap

  • The output would be easier to read if Epheruns's messages were coloured in.

  • Currently only Docker and Podman are available as backends and ephemerun autodetects which one is installed. Perhaps Containerd or something using a Kubernetes cluster could be added without too much difficulty. I would like to support many other mechanisms too (e.g. Systemd Nspawn) but currently everything assumes the image is specified in OCI format.

  • It would be good to mirror -D with an inverse -U to do an upload.

  • I think if -D is used with the docker backend the files will end up being owned by a different user from the one running ephemerun. I think that is undesirable.

  • As the examples show there is an icky problem where the current directory is mounted readonly, but then build commands etc fail, so we have to mount it to a src/ subdirectory and copy the files out. Surely there is a better way. Presumably if -U can recursively upload a directory then we can use that.

  • Many tools can make use of a cache, but anything that gets cached is thrown away by Ephemerun. I do not have a strategy for handling that at the moment.

  • More generally we could do with developing and documenting a strategy for one Makefile recipe to build a reusable image and then different recipes using it for different purposes. Presumably ephemerun wouldn't be used for the building.

Licence

This code is licensed under the terms of the GNU General Public Licence version 3.

Release files for ephemerun 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ephemerun 1.1.2
File Size Uploaded
ephemerun-1.1.2.tar.gz 17.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ephemerun 1.1.2
File Interpreter ABI Platform
ephemerun-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.9 kB

Release files / ephemerun-1.1.2.tar.gz

Download URL ephemerun-1.1.2.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
34fc848c2e88c4623318720b489a8d05970f186ad3fbd090760ee12f1463be7a
BLAKE2b-256 checksum
How to use checksums
cb7ab5a7f57e670b311cac7c763c5fb39bc6236b4e9ee8758f546c62ce0b0b94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / ephemerun-1.1.2-py3-none-any.whl

Download URL ephemerun-1.1.2-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4ac20032efc25cff786cd539b6ae6f4826d482846bdde9cd6afd75f593647cc
BLAKE2b-256 checksum
How to use checksums
fb9577ae5710aad513e4f3e63b9ea011c597fb971b66fd1b55ff9f0abdd8ab6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page