CI/CD | |
Package | |
Meta |
This provides a plugin for Hatch that allows the use of containerized environments.
Table of Contents
pip install hatch-containers
The environment plugin name is container
.
-
pyproject.toml
[tool.hatch.envs.<ENV_NAME>] type = "container"
-
hatch.toml
[envs.<ENV_NAME>] type = "container"
If the Python version is set to a multi-character integer like 310
then it will be interpreted as its <MAJOR>.<MINOR>
form e.g. 3.10
.
If not set, then the <MAJOR>.<MINOR>
version of the first python
found along your PATH
will be used, defaulting to the Python executable Hatch is running on.
The image
option specifies the container image to use e.g. python:alpine
. It recognizes the placeholder value {version}
which will be replaced by the value of the Python option.
Default:
[envs.<ENV_NAME>]
image = "python:{version}"
The command
option specifies the command that the container will execute when started.
Default:
[envs.<ENV_NAME>]
command = ["/bin/sleep", "infinity"]
By default, containers will be started automatically when entered or when running commands and will be stopped immediately after. If you want containers to start automatically upon creation and not be stopped until removal, you can set start-on-creation
to true
.
Default:
[envs.<ENV_NAME>]
start-on-creation = false
The shell
option specifies the executable that will be used when entering containers. By default, this is set to /bin/bash
unless alpine
is in the image name, in which case /bin/ash
will be used instead.
- There must be a
docker
executable along yourPATH
. - The
env-exclude
environment variable filter has no effect.
- Support for Windows containers
- Support for building images
hatch-containers
is distributed under the terms of the MIT license.