Skip to content

Improve DX for devcontainer and docker compose based workflows - #153

Draft
waxlamp wants to merge 2 commits into
mainfrom
container-rev-matching
Draft

Improve DX for devcontainer and docker compose based workflows#153
waxlamp wants to merge 2 commits into
mainfrom
container-rev-matching

Conversation

@waxlamp

@waxlamp waxlamp commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

This PR contains some experimental changes to improve correctness and usability of both the Docker Compose and Dev Container based development workflows. The following changes have been made (but see the commit messages for further detail):

  • Port forwarding is done at the Docker Compose level for Django and the required services. The ports are bound to localhost explicitly, preventing access to those services by default from other hosts on the network.
  • The host user/group ID can be optionally matched to the vscode user in the Docker Compose setup, preventing both permission problems on startup, and the need to run the containers as root.

These changes do not impact the Dev Container setup, which will continue to take advantage of VSCode's various facilities to support this workflow (including, e.g., dynamic port forwarding for services launched during the dev container's lifetime). They just make the Docker Compose workflow work better, and they enable the use of the standalone devcontainer CLI.

TODO:

  • include documentation to explain all this

The directive to reset the port forwarding for the Django container
relies on the VSCode devcontainer extension to perform dynamic port
forwarding, but that leaves a devcontainer CLI runtime with no way to
forward the Django service port to the host. In addition, keeping the
static forwarding for this service does not harm the VSCode devcontainer
UX at all, as that port is forwarded statically, while any others that
arise will be forwarded dynamically.

Furthermore, the comment on the line that resets Django port forwarding
notes that devcontainer forwarding is better since it is localhost-only;
the other change in this commit is to weaken the docker-compose level
port forwarding to explicitly bind to localhost on the host only, rather
than the default of 0.0.0.0 ("all interfaces"). This prevents those
services from being accessible across the local network (and brings it
into line with the devcontainer approach).
This aligns the `vscode` user in the container to have the same UID and
GID as the user on the host. It requires a bit of manual intervention,
but not doing that step will lead to incorrect behavior, and the manual
step can be done at that point, followed by a container rebuild. That is
to say, the situation is near-self-healing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant