Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
gitlab-runner
gitlab-runner
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 2,038
    • Issues 2,038
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 202
    • Merge Requests 202
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • gitlab-runnergitlab-runner
  • Issues
  • #4748

Closed
Open
Opened Oct 01, 2019 by Adam Porteous@Porteous

Add cap_add and devices parameters to supporting services configuration

Description

I would like gitlab-runner to be able to run Docker containers as supporting services with additional parameters such as cap_add and devices.

In time .gitlab-ci.yml could support all options available in [runners.docker]

Proposal - worked example

Example .gitlab-ci.yml file below.

The main job runner is busybox which sleeps for 60 seconds and then exits

A supporting service container selenium/standalone-chrome waits for commands for the duration of the job

job:
  image: busybox
  services:
    - name: selenium/standalone-chrome
  script:
    - echo "About to sleep"
    - sleep 60
    - echo "End of test"

gitlab-runner currently supports flags --cap_add and --devices

gitlab-runner exec docker --docker-cap-add "NET_ADMIN" --docker-devices "/dev/net/tun" "job"

Both busybox and selenium containers are running

adam@adam-dev:/mnt/development/btos$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
7b746fbb8cf2        19485c79a9bb        "sh -c 'if [ -x /usr…"   9 seconds ago       Up 7 seconds                            runner--project-0-concurrent-0-build-4
283665bea3a2        40a30a1980c6        "/opt/bin/entry_poin…"   22 seconds ago      Up 20 seconds       4444/tcp            runner--project-0-concurrent-0-selenium__standalone-chrome-0

However when inspecting the containers, the extra host arguments are only passed to the busybox container, not the selenium container running as a supporting service.

Excerpt of docker inspect from the busybox container. The CapAdd and Devices parameters have been succesfully populated.

"HostConfig": {
    ...
    "CapAdd": [
        "NET_ADMIN"
    ],
    ...
    "Devices": [                                                                   
        {                                                                                                                   
            "PathOnHost": "/dev/net/tun",                                                                              
            "PathInContainer": "/dev/net/tun",                                                                   
            "CgroupPermissions": "rwm"                                                                                                                                             
        }                                         
    ],     
    ...
}

Excerpt of docker inspect from the selenium service container. The CapAdd and Devices parameters have not been populated.

"HostConfig": {
    ...
    "CapAdd": null,
    ...
    "Devices": null,
    ...
}
Assignee
Assign to
Awaiting further demand
Milestone
Awaiting further demand
Assign milestone
Time tracking
None
Due date
None
Reference: gitlab-org/gitlab-runner#4748