Skip to content

Commit c66e9b1

Browse files
committed
Add instructions on how to use the dev container image from GHCR
Along the way make using the container outside of GitHub Codespaces its own section.
1 parent 623218d commit c66e9b1

File tree

1 file changed

+49
-14
lines changed

1 file changed

+49
-14
lines changed

getting-started/setup-building.rst

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,19 +1188,57 @@ select the option ``Open in VS Code``. You will still be working on the remote
11881188
codespace instance, thus using the remote instance's compute power. The compute
11891189
power may be a much higher spec than your local machine which can be helpful.
11901190

1191+
.. c_codespaces_end
1192+
1193+
.. _devcontainer-directly:
11911194

1192-
Building the container locally
1193-
------------------------------
1195+
Using the dev container directly
1196+
================================
11941197

11951198
If you want more control over the environment, or to work offline,
1196-
you can build the container locally.
1199+
you can use the same container used in
1200+
:ref:`GitHub Codespaces <using-codespaces>` directly.
11971201
This is meant for users who have (or want to get) some experience
11981202
with containers.
1199-
The following instructions are a starting point for
1200-
your own customizations.
1201-
They assume a Unix-like environment, and Docker or Podman installed.
1203+
These instructions assume a Unix-like environment with
1204+
`Docker <https://www.docker.com/>`__ or `Podman <https://podman.io/>`__
1205+
installed.
1206+
1207+
.. _devcontainer-image:
1208+
1209+
Using the pre-built container image
1210+
-----------------------------------
1211+
1212+
`Dev container images <https://github.com/python/cpython-devcontainers/pkgs/container/devcontainer>`__
1213+
are available from the
1214+
`GitHub Container Registry (GHCR) account for the Python org <https://github.com/orgs/python/packages>`__ .
1215+
1216+
You can download the latest version of the container image via:
1217+
1218+
.. code-block:: bash
1219+
1220+
docker pull ghcr.io/python/devcontainer:latest
1221+
1222+
(Substitute ``podman`` for ``docker`` if you use Podman.)
12021223

1203-
In a clone of the `cpython-devcontainers repo <https://github.com/python/cpython-devcontainers>`_,
1224+
To run the container and launch a Bash shell, run one of the following commands
1225+
in a clone of the CPython repository.
1226+
1227+
.. code-block:: bash
1228+
1229+
docker run -it --rm --volume $PWD:/workspace --workdir /workspace ghcr.io/python/devcontainer:latest
1230+
1231+
.. code-block:: bash
1232+
1233+
podman run -it --rm --volume $PWD:/workspace:Z --workdir /workspace ghcr.io/python/devcontainer:latest
1234+
1235+
.. _devcontainer-build:
1236+
1237+
Building yourself
1238+
-----------------
1239+
1240+
If you prefer, you can build the container image yourself. In a clone of the
1241+
`cpython-devcontainers repo <https://github.com/python/cpython-devcontainers>`_,
12041242
build the container and name it ``cpython-dev``:
12051243

12061244
.. code-block:: bash
@@ -1213,8 +1251,8 @@ The same command will update any existing ``cpython-dev`` container.
12131251
Run it again from time to time -- especially if the container stops
12141252
working for you.
12151253

1216-
To run the container, run one of the following commands in a clone of the
1217-
CPython repository.
1254+
To run the container and launch a Bash shell, run one of the following commands
1255+
in a clone of the CPython repository.
12181256

12191257
.. code-block:: bash
12201258
@@ -1224,11 +1262,8 @@ CPython repository.
12241262
12251263
podman run -it --rm --volume $PWD:/workspace:Z --workdir /workspace cpython-dev
12261264
1227-
Note that the container has read/write access to the working directory.
1228-
You may want to use a separate clone of CPython, or run ``make clean``
1229-
to remove caches and build output generated for your host OS.
1230-
1231-
.. c_codespaces_end
1265+
The same caveats outlined above when running from a container image from GHCR
1266+
also apply here.
12321267

12331268

12341269

0 commit comments

Comments
 (0)