Skip to content

What is the path resolution context of onCreateCommand when using Docker outside of Docker (DooD)? #1166

@krave1986

Description

@krave1986

Question / Clarification Request

I have a devcontainer setup using Docker Compose with the docker-outside-of-docker feature. My devcontainer.json is as follows:

{
    "name": "hanhanmap-frontend",
    "dockerComposeFile": "compose.yaml",
    "service": "hanhanmap-frontend",
    "workspaceFolder": "/workspace/frontend",
    "onCreateCommand": "docker compose -f .devcontainer/compose.yaml run --rm code-sync",
    "features": {
        "ghcr.io/devcontainers/features/docker-outside-of-docker": {}
    }
}

The dev container is based on Docker Compose, with no bind mounts — only a named volume:

services:
  hanhanmap-frontend:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - volume-of-hanhan:/workspace
    working_dir: /workspace/frontend
    command: sleep infinity
volumes:
  volume-of-hanhan:

The onCreateCommand runs successfullydocker compose -f .devcontainer/compose.yaml run --rm code-sync completes without errors.

However, this raises a question I cannot answer with confidence:

The path .devcontainer/compose.yaml is passed to docker compose -f. Since the docker CLI inside the container communicates with the host's Docker daemon via the socket (DooD), and since .devcontever/compose.yaml does not exist inside the container (no bind mount), how is this path resolved?

Possible explanations:

  1. The docker compose -f <path> resolves the path in the host's filesystem context, not the container's — because the command is ultimately dispatched to the host daemon.
  2. The Dev Containers CLI somehow makes .devcontainer/ available inside the container before onCreateCommand runs.
  3. Something else entirely.

What I'd like to understand:

  • What is the working directory and filesystem context when onCreateCommand runs a docker compose command via DooD?
  • Is this behavior defined in the Dev Container spec, or is it an implementation detail of the VS Code Dev Containers extension?
  • Can I rely on host-side paths being resolvable from within onCreateCommand when using DooD?

Thank you!

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