Skip to content

fix: set default base image in Dockerfiles and improve syntax handling#1242

Draft
sireeshajonnalagadda wants to merge 5 commits into
devcontainers:mainfrom
sireeshajonnalagadda:cli-1229
Draft

fix: set default base image in Dockerfiles and improve syntax handling#1242
sireeshajonnalagadda wants to merge 5 commits into
devcontainers:mainfrom
sireeshajonnalagadda:cli-1229

Conversation

@sireeshajonnalagadda
Copy link
Copy Markdown

@sireeshajonnalagadda sireeshajonnalagadda commented Jun 8, 2026

What issue is about

The warning InvalidDefaultArgInFrom is not from the user’s project Dockerfile.
It comes from internal CLI Dockerfile flows where FROM uses an ARG that can look empty at parse time.
The reported hang after Starting container is likely a separate startup/event path, not this warning itself.
What has been done for you

Root cause was confirmed by tracing internal paths and issue context.
Warning fix was applied in updateUID.Dockerfile:3
ARG BASE_IMAGE changed to ARG BASE_IMAGE=placeholder.
Related hardening changes were also applied in generated feature Dockerfile templates:
containerFeaturesConfiguration.ts
containerFeatures.ts

Validation done

Local CLI build and run path was verified:
npm run compile
node devcontainer.js up --workspace-folder ./src/test/configs/example/ --build-no-cache --remove-existing-container

This succeeded with local source and removed the original BASE_IMAGE warning path in the tested flow.

Current changed files relevant to this issue

updateUID.Dockerfile
containerFeaturesConfiguration.ts
containerFeatures.ts

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR refactors devcontainer features Dockerfile generation/templates to be more resilient when base image build args are not provided, and cleans up formatting/whitespace in a few spots.

Changes:

  • Updates generated Dockerfile content to use ${_DEV_CONTAINERS_BASE_IMAGE:-scratch} and adds placeholder ARG defaults.
  • Adds missing ARG _DEV_CONTAINERS_BASE_IMAGE in the base Dockerfile template and aligns indentation.
  • Minor formatting fixes (brace style, indentation, trailing whitespace, JSON newline).
Show a summary per file
File Description
src/spec-node/containerFeatures.ts Adjusts generated Dockerfile content/prefix and applies formatting cleanups.
src/spec-configuration/containerFeaturesConfiguration.ts Updates base Dockerfile template to declare _DEV_CONTAINERS_BASE_IMAGE and uses a fallback in FROM.
scripts/updateUID.Dockerfile Adds a default value to BASE_IMAGE ARG.
.devcontainer/devcontainer-lock.json Formatting-only newline/EOF adjustment.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (3)

src/spec-node/containerFeatures.ts:1

  • Dockerfile variable substitution does not reliably support shell-style defaulting (${VAR:-scratch}) across Docker/BuildKit versions, and it may be treated as a literal/invalid image reference. Prefer setting the default on the ARG itself (e.g., ARG _DEV_CONTAINERS_BASE_IMAGE=scratch) and then using FROM $_DEV_CONTAINERS_BASE_IMAGE ..., or ensure the build arg is always provided and fail early with a clear error if missing.
/*---------------------------------------------------------------------------------------------

src/spec-configuration/containerFeaturesConfiguration.ts:1

  • Falling back to scratch in these stages can produce confusing build failures if _DEV_CONTAINERS_BASE_IMAGE isn’t set, because this Dockerfile later executes RUN instructions (which will fail on scratch due to the absence of /bin/sh). Consider either: (1) making the ARG default a real minimal base image that supports RUN (if acceptable), or (2) keeping the base image required and adding an explicit, early failure explaining that _DEV_CONTAINERS_BASE_IMAGE must be provided, rather than silently defaulting to scratch.
/*---------------------------------------------------------------------------------------------

src/spec-configuration/containerFeaturesConfiguration.ts:1

  • Falling back to scratch in these stages can produce confusing build failures if _DEV_CONTAINERS_BASE_IMAGE isn’t set, because this Dockerfile later executes RUN instructions (which will fail on scratch due to the absence of /bin/sh). Consider either: (1) making the ARG default a real minimal base image that supports RUN (if acceptable), or (2) keeping the base image required and adding an explicit, early failure explaining that _DEV_CONTAINERS_BASE_IMAGE must be provided, rather than silently defaulting to scratch.
/*---------------------------------------------------------------------------------------------
  • Files reviewed: 3/4 changed files
  • Comments generated: 3

Comment thread src/spec-node/containerFeatures.ts Outdated
Comment thread src/spec-node/containerFeatures.ts Outdated
Comment thread scripts/updateUID.Dockerfile Outdated
Comment on lines 3 to 4
ARG BASE_IMAGE=placeholder
FROM $BASE_IMAGE
Copy link
Copy Markdown
Author

@sireeshajonnalagadda sireeshajonnalagadda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaulting BASE_IMAGE to placeholder will cause builds to fail with an invalid image reference if the build arg is omitted. If the intent is to provide a safe default, use a valid default value (e.g., scratch or a known minimal base)

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.

2 participants