Using docker compose.yml for this is pretty standard and also much easier to maintain, since you are documenting the setup using nicely formatted YAML code rather than hard to remember command line arguments. In addition, it allows configuring more than just one container and having them interoperate for a particular project.
I understand that the container image was developed as part of the Codespaces devcontainer setup, but for some reason people in this thread don’t seem to see the point that binding them to Github Codespaces is not a good way to “make supporting WASI easier”.
Codespaces are great for users who like to work directly in the cloud, but containers can very easily be run offline and locally as well, without any cloud connection, and we should cater to those users as well, IMO, and not make it looks like these containers only work in the context of Codespaces as the docs currently suggest (even though the section for building the containers locally actually does not require Codespaces at all).
A run.py tool may help, but you’d still have to explain where how the interaction between the container and the local dir works and if people want to customize this, they’d have to either edit the Python script or go with a compose.yml file.
IMO, it’s better to stick with standard docker/podman commands, since there’s lots of documentation on how to use these out there - and it’s really not hard to use. docker compose is deliberately easy to use and provides a wrapper around the complicated docker command line.
As for a place to put the compose.yml: you typically put this into your project directory (and the corresponding dockerfile into a docker/ subdir). This enables building images as necessary, when needed.
As for pinning the container image: yes, having tags which allow selecting the right container image for a specific Python version would be great. You’d then name this e.g. 3.14 or similar (and since can have multiple tags with each image, you can add tags for all compatible Python versions to each image).
Note that it’s no big deal to not have such images available either, since docker compose up -d would simply build the container.
Here’s a compose.yml version which does this:
services:
wasi-sdk:
image: ghcr.io/python/devcontainer:latest
container_name: wasi-sdk
build:
context: docker/devcontainer
dockerfile: Dockerfile
pull_policy: missing
restart: unless-stopped
entrypoint: sleep 86400
volumes:
- ./build:/build
It assumes that you have run git clone git@github.com:python/cpython-devcontainers.git docker to download the docker files.
You can then force the build using docker compose build and you can go fully local by commenting out the image: line.
Anyway, I don’t want to write a docker compose tutorial here
and I have repeated my point enough times, I believe.
Perhaps we should just move the section “Building the container locally” to a new section “Contributing without Codespaces” and add another section “Using docker compose to run the container” to that section.