cli icon indicating copy to clipboard operation
cli copied to clipboard

devcontainer features test command inside a container with mounted docker socket -> problems with /tmp

Open Roemer opened this issue 1 year ago • 1 comments

The devcontainer features test (especially for scenarios) creates everything needed in a directory in /tmp. When the container is created, this folder is mounted inside the container (probably for the additional files and the verifying .sh file).

This leads to problems when the devcontainer-cli and the test are running inside a container with a mounted docker socket. The problem is that the /tmp with the correct data is in the container and when creating the test-container and mounting the /tmp, the /tmp from the docker host (outside of the container) is used which does not know the the correct data of course.

I tried to draw this:

/ Docker-Host
├── Docker / Docker Socket
├── container with devcontainer cli
│   ├── workspace
│   │   ├── src
│   │   └── test
│   └── tmp (contains the temporary devcontainer spec)
└── tmp (is mounted when the devcontainer is started)

In some cases this is easy fixable by mounting /tmp from the host to /tmp into the container with the devcontainer cli but sometimes (in some CI scenarios), adding additional mounts is not possible.

My suggestion would be to be able to specify the temporaryPath where all these files are placed. If this path could be specified, it would at least be possible to use some clever symlinking to achieve the same path inside the container with the cli and from the host.

An alternative would be to not need this mount at all and copy all those files during the build of the container into the container so they are directly available.

Roemer avatar Oct 25 '24 14:10 Roemer

This bit me and was reproducible using act at the command line. For my situation, I had to mount /tmp/devcontainercli which seems… suboptimal?

Also it straight-up doesn't work in my remote CI. 😭

---
name: Test Features
on:
  push: 
    branches: [main]
jobs:
  test:
    runs-on: ubuntu-latest
    container:
      image: catthehacker/ubuntu:act-latest
      volumes: ["/tmp/devcontainercli:/tmp/devcontainercli"] # <--
    continue-on-error: true
    steps:
      - uses: actions/checkout@v4
      - name: Install devcontainer CLI
        run: npm install -g @devcontainers/cli}
      - name: Running tests
        run: |-
          devcontainer features test --skip-scenarios .

kreeger avatar Sep 11 '25 22:09 kreeger