@@ -306,3 +306,45 @@ Access full logs
306
306
307
307
If you want to access the full logs you need to write ``-q `` and ``-v `` as
308
308
individual tox arguments and avoid combining them into a single one.
309
+
310
+ Running within a Docker container
311
+ ---------------------------------
312
+
313
+ If you want to run tox within a Docker container you can use `31z4/tox <https://hub.docker.com/r/31z4/tox >`_.
314
+ This Docker image neatly packages tox along with common build dependencies (e.g., ``make ``, ``gcc ``, etc) and currently
315
+ `active CPython versions <https://devguide.python.org/versions/#status-of-python-versions >`_. See more details in
316
+ its `GitHub repository <https://github.com/31z4/tox-docker >`_.
317
+
318
+ The recommended way of using the image is to mount the directory that contains your tox configuration files and your
319
+ code as a volume. Assuming your project is within the current directory of the host, use the following command to run
320
+ tox without any flags:
321
+
322
+ .. code-block :: shell
323
+
324
+ docker run -v ` pwd` :/home/tox/tests -it --rm 31z4/tox
325
+
326
+ Because an entry point of the image is ``tox ``, you can easily pass subcommands and flags:
327
+
328
+ .. code-block :: shell
329
+
330
+ docker run -v ` pwd` :/home/tox/tests -it --rm 31z4/tox run-parallel -e black,py311
331
+
332
+ Note, that the image is configured with a working directory at ``/home/tox/tests ``.
333
+
334
+ If you want to install additional Python versions/implementations or Ubuntu packages you can create a derivative image.
335
+ Just make sure you switch the user to ``root `` when needed and switch back to ``tox `` afterwards:
336
+
337
+ .. code-block :: Dockerfile
338
+
339
+ FROM 31z4/tox
340
+
341
+ USER root
342
+
343
+ RUN set -eux; \
344
+ apt-get update; \
345
+ DEBIAN_FRONTEND=noninteractive \
346
+ apt-get install -y --no-install-recommends \
347
+ python3.12; \
348
+ rm -rf /var/lib/apt/lists/*
349
+
350
+ USER tox
0 commit comments