Skip to content

[Proposal] Expose the container name in remoteEnv #778

Description

A process running in a devcontainer may need its container’s runtime name for logging or tracking purposes. Today, there is no way to reference that name in remoteEnv. The name field in devcontainer.json is a display name and may differ from the name shown by Docker or Podman.

Add a ${containerName} variable that can be used in remoteEnv:

{
  "remoteEnv": {
    "DEVCONTAINER_CONTAINER_NAME": "${containerName}"
  }
}

${containerName} should resolve to the actual runtime name of the primary development container. It should work for both newly created and reused containers, including the primary service in a Docker Compose setup. The tool should resolve it before running lifecycle commands or starting other processes to which remoteEnv applies.

This does not change how containers are named. Because the value is only known after container creation, ${containerName} would not be available in creation-time settings such as containerEnv or runArgs.

Related requests: container name in devcontainer.json (#184) and a CLI option to choose the name (#692).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions