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

runner --driver=github Docker-in-Docker #908

Open
casperdcl opened this issue Mar 9, 2022 · 5 comments
Open

runner --driver=github Docker-in-Docker #908

casperdcl opened this issue Mar 9, 2022 · 5 comments
Labels
ci-github cml-runner Subcommand discussion Waiting for team decision research Waiting for team investigation

Comments

@casperdcl
Copy link
Contributor

casperdcl commented Mar 9, 2022

Docker-in-Docker (probably) doesn't work with GitHub?

(P.S. we recommend --docker-volumes=/var/run/docker.sock:/var/run/docker.sock for GitLab)

jobs:
  deploy:
    steps:
    - run: cml runner --cloud=aws --labels=cml-aws
  train:
    needs: deploy
    runs-on: [self-hosted, cml-aws]
    container:
      image: docker://<some_container>
    steps:
    - uses: [self-hosted, cml-aws]
    - run: docker run ...
  1. Have we tried using docker:dind for <some_container>?
    • Do we need container.volumes: /var/run/docker.sock:/var/run/docker.sock?
  2. Have we confirmed not using a container: works (i.e. Docker-on-baremetal)?
@casperdcl casperdcl added cml-runner Subcommand research Waiting for team investigation ci-github labels Mar 9, 2022
@0x2b3bfa0
Copy link
Member

0x2b3bfa0 commented Mar 9, 2022

Working

GitHub takes care of mounting any volumes it needs for running docker commands inside container jobs.

container: docker:dind

on: workflow_dispatch     
jobs:
  example:
    runs-on: ubuntu-latest
    container: docker:dind
    steps:
    - run: echo FROM python > Dockerfile
    - run: docker build .

container: docker

on: workflow_dispatch     
jobs:
  example:
    runs-on: ubuntu-latest
    container: docker
    steps:
    - run: echo FROM python > Dockerfile
    - run: docker build .

container: alpine + apk add docker

on: workflow_dispatch     
jobs:
  example:
    runs-on: ubuntu-latest
    container: alpine
    steps:
    - run: apk add docker
    - run: echo FROM python > Dockerfile
    - run: docker build .

container: null

on: workflow_dispatch     
jobs:
  example:
    runs-on: ubuntu-latest
    steps:
    - run: echo FROM python > Dockerfile
    - run: docker build .

Not Working

Containerized self–hosted runners don't admit container steps nor container actions.

on: workflow_dispatch     
jobs:
  example:
    runs-on: self-hosted # containerized runner
    container: alpine
    steps:
    - run: date
Error: Container feature is not supported when runner is already running inside container.

📖 As long as users don't set the container option nor use container actions, containerized self–hosted runners will work as expected.

🧙🏼 It's also possible to run docker commands inside a containerized self–hosted runner, as long as the underlying container has the docker command installed and has /var/run/docker.sock mounted to the host or a docker:dind container.

@0x2b3bfa0
Copy link
Member

0x2b3bfa0 commented Mar 10, 2022

What kind of runner / What can be done jobs.<job_id>.container, jobs.<job_id>.services and jobs.<job_id>.steps.*.uses with container actions docker build & docker run
GitHub-hosted runner
self–hosted runner and cml runner 1
containerized self–hosted runner 2 with /var/run/docker.sock from host or docker:dind 🚫
containerized self–hosted runner 3 with no access to /var/run/docker.sock 🚫 🚫

Footnotes

  1. cml runner --repo=https://github.com/user/repository --token=ghp_...

  2. docker run --rm --volume /var/run/docker.sock:/var/run/docker.sock iterativeai/cml runner --repo=https://github.com/user/repository --token=ghp_...

  3. docker run --rm iterativeai/cml runner --repo=https://github.com/user/repository --token=ghp_...

@DavidGOrtega
Copy link
Contributor

DavidGOrtega commented Mar 10, 2022

I was opening another issue to follow up discord/cml#951240652035883008

The idea was to throw an error explaining that volumes in GH are explicitly specified in the yaml instead of current one
Makes sense to follow it up here?

@0x2b3bfa0
Copy link
Member

0x2b3bfa0 commented Mar 11, 2022

This issue is about containerized self–hosted runners. It doesn't seem to be related to the Discord question you link. 🤔

@dacbd
Copy link
Contributor

dacbd commented Feb 17, 2023

we should try to document this somewhere more permanent than in an issue. perhaps the readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-github cml-runner Subcommand discussion Waiting for team decision research Waiting for team investigation
Projects
None yet
Development

No branches or pull requests

4 participants