Skip to content

devcontainers using docker-compose can't find Dockerfile #549

Open

Description

@PureTryOut

I have a project that has an existing docker-compose.yml that I'd like to use. This docker-compose.yml runs a service built from a local Dockerfile, referenced as follows:

build:
      dockerfile: "Dockerfile"
      context: .

My .devcontainer/devcontainer.json is as follows:

{
    "name": "<project name>",
    "dockerComposeFile": "../docker-compose.yml",
    "service": "<service in docker-compose>",
    "workspaceFolder": "/app",
    "shutdownAction": "stopCompose"
}

Opening VSCode using this seemingly simple setup however fails:

[2024-10-18T13:35:07.085Z] Traceback (most recent call last):
  File "/usr/bin/podman-compose", line 8, in <module>
[2024-10-18T13:35:07.085Z]     sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.12/site-packages/podman_compose.py", line 3504, in main
[2024-10-18T13:35:07.086Z]     asyncio.run(async_main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
[2024-10-18T13:35:07.086Z]     return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/podman_compose.py", line 3500, in async_main
[2024-10-18T13:35:07.086Z]     await podman_compose.run()
  File "/usr/lib/python3.12/site-packages/podman_compose.py", line 1743, in run
[2024-10-18T13:35:07.087Z]     retcode = await cmd(self, args)
              ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/podman_compose.py", line 2422, in compose_build
    s = await t
        ^^^^^^^
  File "/usr/lib/python3.12/asyncio/tasks.py", line 631, in _wait_for_one
    return f.result()  # May raise f.exception().
           ^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/podman_compose.py", line 2373, in build_one
[2024-10-18T13:35:07.087Z]     raise OSError("Dockerfile not found in " + ctx)
[2024-10-18T13:35:07.087Z] OSError: Dockerfile not found in /home/<user>/<project>
[2024-10-18T13:35:07.115Z] Error: executing /usr/bin/podman-compose --project-name <project name> -f /home/<user>/<project>/docker-compose.yml -f /home/<user>/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/docker-compose/docker-compose.devcontainer.build-1729258506835.yml build: exit status 1
[2024-10-18T13:35:07.123Z] Stop (287 ms): Run: /home/<user>/.local/bin/podman-host compose --project-name <project name> -f /home/<user>/<project>/docker-compose.yml -f /home/<user>/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/docker-compose/docker-compose.devcontainer.build-1729258506835.yml build
[2024-10-18T13:35:07.126Z] Error: Command failed: /home/<user>/.local/bin/podman-host compose --project-name <project name> -f /home/<user>/<project>/docker-compose.yml -f /home/<user>/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/docker-compose/docker-compose.devcontainer.build-1729258506835.yml build
[2024-10-18T13:35:07.126Z]     at Pm (/home/<user>/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:430:525)
[2024-10-18T13:35:07.126Z]     at async ftA (/home/<user>/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:430:2476)
[2024-10-18T13:35:07.126Z]     at async htA (/home/<user>/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:410:3496)
[2024-10-18T13:35:07.126Z]     at async TtA (/home/<user>/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:482:4021)
[2024-10-18T13:35:07.126Z]     at async iB (/home/<user>/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:482:4963)
[2024-10-18T13:35:07.126Z]     at async wrA (/home/<user>/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:663:203)
[2024-10-18T13:35:07.126Z]     at async DrA (/home/<user>/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:662:14830)
[2024-10-18T13:35:07.127Z]     at async /home/<user>/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:482:1190
[2024-10-18T13:35:07.143Z] Stop (1298 ms): Run: /app/extra/vscode/code /home/<user>/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/<user>/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --docker-path /home/<user>/.local/bin/podman-host --container-session-data-folder /tmp/devcontainers-1248c3b6-2a23-4114-a0b8-e99fac641c2c1729258504414 --workspace-folder /home<user>/<project> --workspace-mount-consistency cached --gpu-availability detect --id-label devcontainer.local_folder=/home/<user>/<project> --id-label devcontainer.config_file=/home/<user>/<project>/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/<user>/<project>/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root --include-configuration --include-merged-configuration
[2024-10-18T13:35:07.143Z] Exit code 1
[2024-10-18T13:35:07.151Z] Command failed: /app/extra/vscode/code /home/<user>/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/<user>/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --docker-path /home/<user>/.local/bin/podman-host --container-session-data-folder /tmp/devcontainers-1248c3b6-2a23-4114-a0b8-e99fac641c2c1729258504414 --workspace-folder /home/<user>/<project> --workspace-mount-consistency cached --gpu-availability detect --id-label devcontainer.local_folder=/home/<user>/<project> --id-label devcontainer.config_file=/home/<user>/<project>/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/<user>/<project>/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root --include-configuration --include-merged-configuration
[2024-10-18T13:35:07.151Z] Exit code 1

OSError: Dockerfile not found in /home/<user>/<project> seems weird to me, because the Dockerfile is there. Outside of VSCode and Flatpak and what not I can build this Docker (well, Podman really) setup just fine, so I'm guessing the Flatpak sandbox is in the way somehow?

Activity

  1. PureTryOut commented on Feb 10, 2025

    @PureTryOut
    Author

    Digging a bit further, I guess I found the issue. Above the log I already posted there is this:

    [2025-02-10T10:03:46.797Z] Docker Compose override file for building image:
    services:
      beep:
        build:
          dockerfile: /tmp/devcontainercli-<user>/container-features/0.73.0-1739181826795/Dockerfile-with-features
          args:
            - BUILDKIT_INLINE_CACHE=1
            - _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label
    

    /tmp/devcontainercli-bart/container-features/0.73.0-1739181826795/Dockerfile-with-features is not a file that exists on my system. Maybe (probably) it exists in the Flatpak sandbox but podman/Docker of course doesn't run there and it would fail to find this file. Since the Python stacktrace doesn't actually list the Dockerfile it's trying to find I'm guessing it's this one.

    This means however that it's impossible to use a Flatpakked VSCode with devcontainers, which would be the ideal setup...

  2. francoism90 commented on Apr 7, 2025

    @francoism90

    You should use a ./ in the build:

    "build": {
            "dockerfile": "./../containers/dev.Dockerfile",
            "context": "./../containers",
            "args": {
                "--format": "docker"
            }
        }
  3. m2Giles commented on May 11, 2025

    @m2Giles

    I'm assuming you are using either podman-remote or flatpak --spawn to use your host's container engine.

    Unfortunately, the devcontainer build process writes to /tmp. Since the container-engine is running outside the sandbox the build-process doesn't see that file anymore.

    Solution. Use a filesystem override to add /tmp however, this may expose stuff you didn't want to the flatpak

  4. bam80 commented on Jun 1, 2026

    @bam80

    Any way this could be solved for good?

  5. PureTryOut commented on Jun 2, 2026

    @PureTryOut
    Author

    Yeah /tmp is not something I'd want to give VSCode access too. Ideally something makes this work out of the box.

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