conflicting-container-def

disallow a devcontainer.json that defines more than one of “image”, “build”, or “dockerComposeFile”

Category
correctness
Applies to
devcontainer
Platforms
all

Why

The specification defines three mutually exclusive ways to create the container: from an image, from a Dockerfile, or from a Docker Compose project. Which one wins when several are set is unspecified, so the container that gets built depends on the tool rather than on the configuration. Keep the variant the project actually uses and remove the others.

Bad

{
  "name": "my project",
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "build": {
    "dockerfile": "Dockerfile"
  }
}

Good

{
  "name": "my project",
  "build": {
    "dockerfile": "Dockerfile"
  }
}

References