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

Add option to remove container when action is done #285

Open
savvn001 opened this issue Mar 20, 2024 · 5 comments
Open

Add option to remove container when action is done #285

savvn001 opened this issue Mar 20, 2024 · 5 comments
Assignees
Labels
feature New feature

Comments

@savvn001
Copy link

savvn001 commented Mar 20, 2024

Hi, I'm getting the following error when Github actions is trying to start a container and run commands. I have a simple workflow file, running on a self hosted runner.

name: run-tests
run-name: ${{ github.actor }} is running
on:
  push:
    # Sequence of patterns matched against refs/heads
    branches:    
      - develop
  workflow_dispatch:

env:
  ARCH: amd64

jobs:
  run-tests:
    runs-on: self-hosted
    steps:
      
      - uses: actions/checkout@v4
      
      - name: Build and run dev container task
        uses: devcontainers/[email protected]
        with:
          # ci.sh script builds and runs all unit tests 
          runCmd: chmod +x ./ci.sh && ./ci.sh
        env:
          ARCH: amd64

Github actions can build the dev container, but fails at the "run command in container" step of the "Build and run dev container" task.

🚀 Run command in container
  About to run devcontainer exec --workspace-folder /home/me/actions-runner/_work/my_repo --remote-env GITHUB_OUTPUT=/mnt/github/output --remote-env GITHUB_ENV=/mnt/github/env --remote-env GITHUB_PATH=/mnt/github/path --remote-env GITHUB_STEP_SUMMARY=/mnt/github/step-summary bash -c chmod +x ./ci.sh && ./ci.sh

  OCI runtime exec failed: exec failed: unable to start container process: current working directory is outside of container mount namespace root -- possible container breakout detected: unknown
  
  Error: Dev container exec failed: (exit code: 126)
  Error: Dev container exec failed: (exit code: 126)

I'm not sure exactly where this is originating from. If I cd to /home/me/actions-runner/_work/my_repo and do devcontainer exec --workspace-folder . I get the same error msg:

OCI runtime exec failed: exec failed: unable to start container process: current working directory is outside of container mount namespace root -- possible container breakout detected: unknown

@savvn001
Copy link
Author

I should add, dev containers normally works fine when I use it directly in my project repo.

I can do devcontainer up --workspace-folder . and then do devcontainer exec --workspace-folder . <some command> with no issues at all.

@chrmarti
Copy link
Collaborator

This looks like opencontainers/runc@8e1cd2f which made it into runc 1.1.12. You can check the runc version with docker version.

@chrmarti chrmarti self-assigned this Mar 26, 2024
@chrmarti chrmarti added the info-needed Issue requires more information from poster label Mar 26, 2024
@savvn001
Copy link
Author

savvn001 commented Apr 9, 2024

@chrmarti Sorry, to update this issue, this issue only happens when there was an issue with the container itself, and it didn't stop properly, and then on the next run it tries to start that same container.

For some reason the devcontainer ci doesn't clean up after itself. I added an extra step in GH actions to manually stop and prune all containers so that it always starts a fresh one on the next run:


      # Devcontainers CLI doesn't clean up at all. So stop, remove and
      # manually prune container
      - name: Clean up stopped container
        run: docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) && docker container prune -f 

@savvn001
Copy link
Author

savvn001 commented Apr 9, 2024

Otherwise, docker version is:


Client: Docker Engine - Community
 Version:           25.0.5
 API version:       1.44
 Go version:        go1.21.8
 Git commit:        5dc9bcc
 Built:             Tue Mar 19 15:05:18 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          25.0.5
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       e63daec
  Built:            Tue Mar 19 15:05:18 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

@chrmarti
Copy link
Collaborator

We could add an option to remove the container when the action is done.

@chrmarti chrmarti changed the title Github Actions: "unable to start container process: current working directory is outside of container mount namespace root" Add option to remove container when action is done Apr 10, 2024
@chrmarti chrmarti added feature New feature and removed info-needed Issue requires more information from poster labels Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

No branches or pull requests

2 participants