Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using dockerComposeFile via podman-compose, resolves Dockerfile in wrong directory (ENOENT on Dockerfile) #7071

Open
hunterloftis opened this issue Aug 15, 2022 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers podman Dev Container using Podman

Comments

@hunterloftis
Copy link

  • VSCode Version: 1.70.0 (flatpak)
  • Local OS Version: SteamOS (Arch linux)
  • Remote OS Version: N/A
  • Remote Extension/Connection Type: N/A
  • Logs:
[2022-08-15T13:58:23.111Z] Remote-Containers 0.245.0 in VS Code 1.70.0 (da76f93349a72022ca4670c1b84860304616aaa2).
[2022-08-15T13:58:23.111Z] Start: Resolving Remote
[2022-08-15T13:58:23.159Z] Setting up container for folder or workspace: /home/deck/test/node-pg
[2022-08-15T13:58:23.164Z] Start: Check Docker is running
[2022-08-15T13:58:23.165Z] Start: Run: /home/deck/flatpak/docker version --format {{.Server.APIVersion}}
[2022-08-15T13:58:23.383Z] Stop (218 ms): Run: /home/deck/flatpak/docker version --format {{.Server.APIVersion}}
[2022-08-15T13:58:23.385Z] Server API version: 3.4.4
[2022-08-15T13:58:23.385Z] Stop (221 ms): Check Docker is running
[2022-08-15T13:58:23.388Z] Start: Run: /home/deck/flatpak/docker volume ls -q
[2022-08-15T13:58:23.589Z] Stop (201 ms): Run: /home/deck/flatpak/docker volume ls -q
[2022-08-15T13:58:23.607Z] Start: Run: /home/deck/flatpak/docker ps -q -a --filter label=vsch.local.folder=/home/deck/test/node-pg --filter label=vsch.quality=stable
[2022-08-15T13:58:23.799Z] Stop (192 ms): Run: /home/deck/flatpak/docker ps -q -a --filter label=vsch.local.folder=/home/deck/test/node-pg --filter label=vsch.quality=stable
[2022-08-15T13:58:23.800Z] Start: Run: /home/deck/flatpak/docker ps -q -a --filter label=devcontainer.local_folder=/home/deck/test/node-pg
[2022-08-15T13:58:23.989Z] Stop (189 ms): Run: /home/deck/flatpak/docker ps -q -a --filter label=devcontainer.local_folder=/home/deck/test/node-pg
[2022-08-15T13:58:23.992Z] Start: Run: /app/extra/vscode/code /home/deck/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.245.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/deck/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --docker-path /home/deck/flatpak/docker --docker-compose-path /home/deck/flatpak/docker-compose --workspace-folder /home/deck/test/node-pg --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/deck/test/node-pg --log-level debug --log-format json --config /home/deck/test/node-pg/.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 true
[2022-08-15T13:58:24.260Z] remote-containers 0.245.0.
[2022-08-15T13:58:24.260Z] Start: Run: /home/deck/flatpak/docker buildx version
[2022-08-15T13:58:24.343Z] Stop (83 ms): Run: /home/deck/flatpak/docker buildx version
[2022-08-15T13:58:24.343Z] Start: Resolving Remote
[2022-08-15T13:58:24.348Z] Start: Run: /home/deck/flatpak/docker-compose version --short
[2022-08-15T13:58:24.588Z] Stop (240 ms): Run: /home/deck/flatpak/docker-compose version --short
[2022-08-15T13:58:24.590Z] Start: Run: /home/deck/flatpak/docker ps -q -a --filter label=com.docker.compose.project=nodepgdevcontainer --filter label=com.docker.compose.service=app
[2022-08-15T13:58:24.774Z] Stop (184 ms): Run: /home/deck/flatpak/docker ps -q -a --filter label=com.docker.compose.project=nodepgdevcontainer --filter label=com.docker.compose.service=app
[2022-08-15T13:58:24.776Z] Start: Run: /home/deck/flatpak/docker-compose -f /home/deck/test/node-pg/.devcontainer/docker-compose.yml config
[2022-08-15T13:58:25.019Z] Stop (243 ms): Run: /home/deck/flatpak/docker-compose -f /home/deck/test/node-pg/.devcontainer/docker-compose.yml config
[2022-08-15T13:58:25.019Z] services:
  app:
    build:
      args:
        VARIANT: '18'
      context: .
      dockerfile: Dockerfile
    command: sleep infinity
    network_mode: service:db
    volumes:
    - ..:/workspace:cached
  db:
    environment:
      POSTGRES_DB: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
    image: postgres:latest
    restart: unless-stopped
    volumes:
    - postgres-data:/var/lib/postgresql/data
version: '3.8'
volumes:
  postgres-data: null

[2022-08-15T13:58:25.025Z] Start: Run: /home/deck/flatpak/docker -v
[2022-08-15T13:58:25.187Z] Stop (162 ms): Run: /home/deck/flatpak/docker -v
[2022-08-15T13:58:25.188Z] Start: Run: /home/deck/flatpak/docker events --format json --filter event=start
[2022-08-15T13:58:25.194Z] PersistedPath=/home/deck/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data, ContainerHasLabels=false
[2022-08-15T13:58:25.195Z] Start: Run: /home/deck/flatpak/docker-compose -f /home/deck/test/node-pg/.devcontainer/docker-compose.yml config
[2022-08-15T13:58:25.421Z] Stop (226 ms): Run: /home/deck/flatpak/docker-compose -f /home/deck/test/node-pg/.devcontainer/docker-compose.yml config
[2022-08-15T13:58:25.421Z] services:
  app:
    build:
      args:
        VARIANT: '18'
      context: .
      dockerfile: Dockerfile
    command: sleep infinity
    network_mode: service:db
    volumes:
    - ..:/workspace:cached
  db:
    environment:
      POSTGRES_DB: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
    image: postgres:latest
    restart: unless-stopped
    volumes:
    - postgres-data:/var/lib/postgresql/data
version: '3.8'
volumes:
  postgres-data: null

[2022-08-15T13:58:25.424Z] Error: ENOENT: no such file or directory, open '/home/deck/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.245.0/Dockerfile'
[2022-08-15T13:58:25.432Z] Stop (1440 ms): Run: /app/extra/vscode/code /home/deck/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.245.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/deck/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --docker-path /home/deck/flatpak/docker --docker-compose-path /home/deck/flatpak/docker-compose --workspace-folder /home/deck/test/node-pg --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/deck/test/node-pg --log-level debug --log-format json --config /home/deck/test/node-pg/.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 true
[2022-08-15T13:58:25.433Z] Exit code 1
[2022-08-15T13:58:25.442Z] Command failed: /app/extra/vscode/code /home/deck/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.245.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/deck/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --docker-path /home/deck/flatpak/docker --docker-compose-path /home/deck/flatpak/docker-compose --workspace-folder /home/deck/test/node-pg --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/deck/test/node-pg --log-level debug --log-format json --config /home/deck/test/node-pg/.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 true
[2022-08-15T13:58:25.442Z] Exit code 1

Steps to Reproduce:

  1. install vscode flatpak
  2. install remote-containers extension
  3. install podman@latest and podman-compose@devel, provide shims to invoke from within flatpak
  4. create a new devcontainer config via the default "node.js + postgres" wizard
  5. update config to work around podman compatibility issues (below)
  6. try to open the container & see the above logs

Alternatively (sorry, only useful on a steam deck):

  1. install https://github.com/hunterloftis/dotfiles on a steam deck
  2. open ~/test/node-pg in a devcontainer
  3. see the above failure
        "remoteUser": "node",
	// https://blog.lifeishao.com/2021/12/30/replacing-docker-with-podman-for-your-vscode-devcontainers/
	"runArgs": [
		"--userns=keep-id"
	],
	"containerUser": "node" // the value needs to match the value of "remoteUser"
@github-actions github-actions bot added the containers Issue in vscode-remote containers label Aug 15, 2022
@donaldlaforce
Copy link

I believe this may be the same problem I was having: #6815 (comment)

On that issue, it was fixed for Docker, but it was not fixed for Podman.

Can you try downgrading to "Remote - Containers" v0.234.0? - I believe this is last version that worked before Podman compose files started being called relative to the remote-containers

@chrmarti
Copy link
Contributor

chrmarti commented Sep 8, 2022

podman-compose config does not resolve the context to an absolute path. We need to handle that here: https://github.com/devcontainers/cli/blob/6278ab6033ddd056d5ab9923b1b9970575433d51/src/spec-node/dockerCompose.ts#L158

@chrmarti chrmarti self-assigned this Sep 8, 2022
@chrmarti chrmarti added the bug Issue identified by VS Code Team member as probable bug label Sep 8, 2022
@warrenseine
Copy link

warrenseine commented Dec 21, 2022

Since OP didn't confirm, I will. The issue is still happening in v0.266.1 and yes, rolling back to v0.234.0 seems to resolve it. I'll watch this issue for updates.

@Diftraku
Copy link

Diftraku commented Feb 9, 2023

Can confirm this happens with both the current release (v0.275.1) and pre-release (v0.278.0) versions, downgrading to v0.234.0 at least gets the build going unlike with the more recent versions.

@pdf
Copy link

pdf commented Apr 26, 2023

Still an issue on v0.288.1, based on the error message, seems like the current working directory just needs to be set to the .devcontainer path, or an unqualified Dockerfile needs to have the expanded path prepended before calling out?

@minhio
Copy link

minhio commented Jul 21, 2023

still an issue on v0.302.0 (pre-release)

@chrmarti chrmarti added the podman Dev Container using Podman label Jul 21, 2023
@virzak
Copy link

virzak commented Feb 16, 2024

Can this please be fixed? This holds me up from using podman-compose. Thanks.

@jwmullally
Copy link

jwmullally commented Mar 29, 2024

I ran into this issue under Fedora 39 using podman. Here is a workaround using a wrapper script for podman-compose:

#!/bin/sh
set -e

# Workaround https://github.com/microsoft/vscode-remote-release/issues/7071
# "Using dockerComposeFile via podman-compose, resolves Dockerfile in wrong directory (ENOENT on Dockerfile)"
# Save this script to somewhere like /usr/local/bin/podman-compose-vscode-workaround
# then in vscode settings, set "dev.containers.dockerComposePath" = "podman-compose-vscode-workaround"
# instead of "podman-compose".
#
# Using information from the parent process, set a VSCODE_WORKSPACE_FOLDER
# environment variable that can be optionally used in docker-compose.yaml
# to set an absolute path for the context:
#
#   version: '3'
#   services:
#     myapp:
#       build: 
#         context: ${VSCODE_WORKSPACE_FOLDER:-..}
#         dockerfile: .devcontainer/Dockerfile

VSCODE_WORKSPACE_FOLDER="$(grep -aoP "\x00--workspace-folder\x00\K[^\x00]+" /proc/$PPID/cmdline || true)"

export VSCODE_WORKSPACE_FOLDER
exec podman-compose $@

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers podman Dev Container using Podman
Projects
None yet
Development

No branches or pull requests

9 participants