Skip to content

Instructions to run the devcontainer locally #1568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion getting-started/setup-building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,45 @@ select the option ``Open in VS Code``. You will still be working on the remote
codespace instance, thus using the remote instance's compute power. The compute
power may be a much higher spec than your local machine which can be helpful.

.. TODO: add docker instructions

Building the container locally
------------------------------

If you want more control over the environment, or to work offline,
you can build the container locally.
This is meant for users who have (or want to get) some experience
with containers.
The following instructions are a starting point for
your own customizations.
They assume a Unix-like environment, and Docker or Podman installed.

In a clone of the `cpython-devcontainers repo <https://github.com/python/cpython-devcontainers>`_,
build the container and name it ``cpython-dev``:

.. code-block:: bash

docker build devcontainer/ --tag cpython-dev

(Substitute ``podman`` for ``docker`` if you use Podman.)

The same command will update any existing ``cpython-dev`` container.
Run it again from time to time -- especially if the container stops
working for you.

To run the container, run one of the following commands in a clone of the
CPython repository.

.. code-block:: bash

docker run -it --rm --volume $PWD:/workspace --workdir /workspace cpython-dev

.. code-block:: bash

podman run -it --rm --volume $PWD:/workspace:Z --workdir /workspace cpython-dev

Note that the container has read/write access to the working directory.
You may want to use a separate clone of CPython, or run ``make clean``
to remove caches and build output generated for your host OS.

.. c_codespaces_end

Expand Down
Loading