Skip to content

Using Dev Containers

JS Ng edited this page May 30, 2025 · 2 revisions

Creating a dev container

To manage dev containers through VSCode, install the following extensions:

  • Container Tools (publisher: microsoft.com)
  • Dev Containers (publisher: microsoft.com)
  1. To create a new dev container, click Remote Window > New Dev Container. For Python 3, I recommend "Python 3" by Github devcontainers.

  2. Click Additional Options, select 3.11-bookworm (for Windows/Linux systems), or 3.11-bullseye (for Macbook on M-series CPU). This will install Python 3.11 for the dev container.

  3. Under Select Features, search for and enable the following:

    • Poetry (via pipx), in devcontainers-extra

    Click OK.

  4. If prompted, trust the Github owner/organizations. Since anybody with an account can publish features or container images, be careful with what you install. Generally, container images and features published by Microsoft and Github are safe to use.

  5. If prompted to include optional files/directories, do not select any. Click OK.

Docker will now build your dev container, and you can click the bottom-right notification to see its progress. It will download ("pull") the container image from Github, run the commands to install the requested features, and prepare it for use.

When ready, you will see the Remote Window button expand to include the text "Dev Container: Python 3 @ desktop-linux" (or a similar descriptor). Congratulations, you are now running in a dev container!

to close the container, click Remote Window > Close Remote Connection or File > Close Remote Connection.

Connecting to a dev container

After you have created a dev container, it is saved on your laptop, and VSCode can connect to it again (if Docker Desktop is running in the background).

  1. Click Remote Window > Attach to Running Container....
  2. Select the container you created previously.
  3. The container will open in a new VSCode window. If the container is not running, you may be prompted to start it.

Removing unused dev containers

As you create new containers, and those containers create new images, you may find that you have to remove old images and containers so that they do not take up space on your system.

  1. Open Docker Desktop > Containers.
  2. Click the red bin icon for any containers you wish to delete.

Clone this wiki locally