Official Black Docker images are available on Docker Hub.
Black images with the following tags are available:
21.5b2, 21.6b0, 21.7b0 etc.latest_release - tag created when a new version of Black is released.latest_prerelease - tag created when a new alpha (prerelease) version of Black is released.latest - tag used for the newest image of Black.There is one more tag used for Black Docker images - latest_non_release. It is created for all unreleased commits on the main branch. This tag is not meant to be used by external users.
From version 23.11.0 the Docker image installs a compiled black into the image.
A permanent container doesn‘t have to be created to use Black as a Docker image. It’s enough to run Black commands for the chosen image denoted as :tag. In the below examples, the latest_release tag is used. If :tag is omitted, the latest tag will be used.
More about Black usage can be found in Usage and Configuration: The basics.
$ docker run --rm pyfound/black:latest_release black --version
$ docker run --rm --volume $(pwd):/src --workdir /src pyfound/black:latest_release black --check .
Remark: besides regular Black exit codes returned by --check option, Docker exit codes should also be considered.