Skip to content

dev_container: Fix various startup issues#53170

Open
zdeneklapes wants to merge 3 commits into
zed-industries:mainfrom
zdeneklapes:fixes/dev-containers
Open

dev_container: Fix various startup issues#53170
zdeneklapes wants to merge 3 commits into
zed-industries:mainfrom
zdeneklapes:fixes/dev-containers

Conversation

@zdeneklapes
Copy link
Copy Markdown

Summary

This merge request fixes multiple dev-container startup issues.

It improves Docker Compose path resolution, preserves compose build configuration when generating
feature builds, hardens remote user detection, and fixes Docker inspect parsing for images that omit
Config.Labels. Together, these changes make dev containers more reliable across a wider range of
setups, including plain base images such as debian:bookworm-slim.

Per-Commit Breakdown

  1. 43dc3cb devcontainer fixed
    This commit contains the main dev-container fixes.
    • Fixes Docker Compose dockerfile and build-context resolution, including cases where the Dockerfile lives outside the .devcontainer directory.
    • Preserves compose build args, volumes, and additional contexts when Zed generates feature-build overrides.
    • Improves remote user resolution by falling back through remoteUser, containerUser, image user, and finally root.
    • Fixes Docker chown invocation to use the resolved remote user correctly.
    • Updates remote server build logic to use the active rustup toolchain and stable workspace-root binary paths.
    • Adds regression coverage for compose configs, remote user fallback, and remote server path
      handling.
  2. 0220310 dont require labels
    This commit fixes startup for images whose docker inspect output does not include Config.Labels.
    • Makes Docker inspect deserialization tolerant of missing Labels.
    • Adds a regression test based on a real debian:bookworm-slim inspect payload.
    • Prevents dev-container startup from failing with missing field Labels on plain images.

Why These Changes Were Needed

Dev container startup was failing in several valid configurations:

  • some Docker Compose setups used dockerfiles or build contexts that were not resolved correctly
  • some images did not provide enough metadata for strict remote-user resolution
  • some base images omitted Config.Labels entirely, which caused Docker inspect deserialization to fail

These changes make the implementation more tolerant of real-world Docker and Compose outputs while keeping the existing dev-container flow intact.

Release Notes

  • Fixed dev container startup for Docker Compose setups with non-standard dockerfile/build-context
    layouts and for images whose docker inspect output omits Config.Labels

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 4, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @zdeneklapes on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Apr 4, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator Bot requested review from a team, cole-miller and reflectronic and removed request for a team April 4, 2026 21:16
@zdeneklapes
Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 5, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 5, 2026

The cla-bot has been summoned, and re-checked this pull request!

@MrSubidubi MrSubidubi changed the title Fixes/dev containers dev_container: Fix various startup issues Apr 6, 2026
@antont
Copy link
Copy Markdown
Contributor

antont commented Apr 14, 2026

Hey @zdeneklapes thanks for the fixes! I'm just a user here, who encountered similar problems, and I'm now taking the Dockerfile path resolution fixes to use in the build I use for daily work.

However, I extracted the fix to only that problem in a dedicated branch, as I did not have time to check the other things and I don't want to have extra risks. I opened a PR with just the Dockerfile path fix too, #53860

The zed devs will decide what to do with the fixes, I'm just mentioning for info.

KyleBarton pushed a commit that referenced this pull request Apr 16, 2026
…ext (#53860)

## Context

When a Docker Compose service specifies `context: ..` and `dockerfile:
.devcontainer/Dockerfile`, Zed resolves the dockerfile path relative to
the compose file's directory instead of the build context. This produces
a doubled path like `.devcontainer/.devcontainer/Dockerfile` which
doesn't exist.

Per the [Docker Compose
spec](https://docs.docker.com/reference/compose-file/build/#dockerfile),
the `dockerfile` field is relative to the build context directory.

The fix resolves the context directory first (relative to the compose
file), then joins the dockerfile path to that.

Closes #53473

## Prior art

This fix is extracted from #53170 by @zdeneklapes, which addresses this
bug among several other dev container startup issues. This PR isolates
the dockerfile path resolution fix into a focused change to make it
easier to review and merge independently.

Differences from #53170:
- **Scope**: Only the dockerfile-relative-to-context fix, not the other
fixes (compose build args preservation, remote user fallback, Docker
inspect labels, etc.)
- **Implementation**: Inline resolution in `dockerfile_location()`
rather than separate helper methods
- **Absolute path handling**: Handles absolute dockerfile and context
paths
- **Tests**: Two test cases — compose file inside `.devcontainer/` with
`context: ..`, and compose file at project root with `context: .`

## How to Review

Single file change in
`crates/dev_container/src/devcontainer_manifest.rs`:
- **Fix** (line 234-252): Resolve build context relative to compose file
directory, then join dockerfile to that, instead of joining dockerfile
to `config_directory` directly. Uses `normalize_path` to resolve `..`
components.
- **Tests**: Two new `FakeDocker` compose config entries and
corresponding tests asserting correct resolved paths.

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed docker-compose `dockerfile` path being resolved relative to the
compose file instead of the build `context` directory.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@reflectronic reflectronic removed their request for review April 16, 2026 19:12
G36maid pushed a commit to G36maid/zed that referenced this pull request Apr 29, 2026
…ext (zed-industries#53860)

## Context

When a Docker Compose service specifies `context: ..` and `dockerfile:
.devcontainer/Dockerfile`, Zed resolves the dockerfile path relative to
the compose file's directory instead of the build context. This produces
a doubled path like `.devcontainer/.devcontainer/Dockerfile` which
doesn't exist.

Per the [Docker Compose
spec](https://docs.docker.com/reference/compose-file/build/#dockerfile),
the `dockerfile` field is relative to the build context directory.

The fix resolves the context directory first (relative to the compose
file), then joins the dockerfile path to that.

Closes zed-industries#53473

## Prior art

This fix is extracted from zed-industries#53170 by @zdeneklapes, which addresses this
bug among several other dev container startup issues. This PR isolates
the dockerfile path resolution fix into a focused change to make it
easier to review and merge independently.

Differences from zed-industries#53170:
- **Scope**: Only the dockerfile-relative-to-context fix, not the other
fixes (compose build args preservation, remote user fallback, Docker
inspect labels, etc.)
- **Implementation**: Inline resolution in `dockerfile_location()`
rather than separate helper methods
- **Absolute path handling**: Handles absolute dockerfile and context
paths
- **Tests**: Two test cases — compose file inside `.devcontainer/` with
`context: ..`, and compose file at project root with `context: .`

## How to Review

Single file change in
`crates/dev_container/src/devcontainer_manifest.rs`:
- **Fix** (line 234-252): Resolve build context relative to compose file
directory, then join dockerfile to that, instead of joining dockerfile
to `config_directory` directly. Uses `normalize_path` to resolve `..`
components.
- **Tests**: Two new `FakeDocker` compose config entries and
corresponding tests asserting correct resolved paths.

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed docker-compose `dockerfile` path being resolved relative to the
compose file instead of the build `context` directory.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
kathbigra pushed a commit to kathbigra/zed that referenced this pull request May 10, 2026
…ext (zed-industries#53860)

## Context

When a Docker Compose service specifies `context: ..` and `dockerfile:
.devcontainer/Dockerfile`, Zed resolves the dockerfile path relative to
the compose file's directory instead of the build context. This produces
a doubled path like `.devcontainer/.devcontainer/Dockerfile` which
doesn't exist.

Per the [Docker Compose
spec](https://docs.docker.com/reference/compose-file/build/#dockerfile),
the `dockerfile` field is relative to the build context directory.

The fix resolves the context directory first (relative to the compose
file), then joins the dockerfile path to that.

Closes zed-industries#53473

## Prior art

This fix is extracted from zed-industries#53170 by @zdeneklapes, which addresses this
bug among several other dev container startup issues. This PR isolates
the dockerfile path resolution fix into a focused change to make it
easier to review and merge independently.

Differences from zed-industries#53170:
- **Scope**: Only the dockerfile-relative-to-context fix, not the other
fixes (compose build args preservation, remote user fallback, Docker
inspect labels, etc.)
- **Implementation**: Inline resolution in `dockerfile_location()`
rather than separate helper methods
- **Absolute path handling**: Handles absolute dockerfile and context
paths
- **Tests**: Two test cases — compose file inside `.devcontainer/` with
`context: ..`, and compose file at project root with `context: .`

## How to Review

Single file change in
`crates/dev_container/src/devcontainer_manifest.rs`:
- **Fix** (line 234-252): Resolve build context relative to compose file
directory, then join dockerfile to that, instead of joining dockerfile
to `config_directory` directly. Uses `normalize_path` to resolve `..`
components.
- **Tests**: Two new `FakeDocker` compose config entries and
corresponding tests asserting correct resolved paths.

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed docker-compose `dockerfile` path being resolved relative to the
compose file instead of the build `context` directory.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants