Shakiba Moshiri
  • Shakiba Moshiri (شکیبا مشیری)
  • opt
    • high traffic site optimization
      • infrastructure check
      • infrastructure test
  • tools
    • Cryptsetup
      • Container encryption using cryptsetup
    • curly
      • ftp
      • ssl
      • http
      • dns
      • ip
      • email
    • SSH
      • ssh password-less login
        • Untitled
    • volumes and FS
      • installing Gluster fs on Ubuntu 18.04 server
      • Accessing Gluster FS from the client machine
  • CDN
    • How does a CDN work
  • Server Panel
  • DirectAdmin
    • DirectAdmin through a reverse proxy
  • Web Server
    • Nginx
      • Live Steaming with Nginx and FFMPEG
  • Security
  • Container
    • Docker Networking 101
      • why docker networking is important?
      • type of networking in docker
    • Docker
      • How to run gitlab-runner with docker
      • using vim inside any container without installing it
      • Cannot connect to the Docker daemon at unix:///var/run/docker.sock
      • moving docker images around using ssh and pipe
      • How can I make docker-compose pull images using a socks5 proxy?
  • Stack Overflow
  • Github
  • vmware
    • tools
      • how to install vmware CLI govc on Linux
  • Windows
    • How to Erase a Recovery Partition in Windows
Powered by GitBook
On this page
  • How to run gitlab-runner with Docker
  • running the whole process in one script

Was this helpful?

  1. Container
  2. Docker

How to run gitlab-runner with docker

How to run gitlab-runner with Docker

PreviousDockerNextusing vim inside any container without installing it

Last updated 4 years ago

Was this helpful?

How to run gitlab-runner with Docker

The official .

create a docker volume

docker volume create gitlab-runner-config

run the gitlab-runner container

docker run -d --name gitlab-runner --restart always \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v gitlab-runner-config:/etc/gitlab-runner \
    gitlab/gitlab-runner:latest

register a project with gitlab-ruuner container ( it is in interactive mode)

docker run --rm -it -v gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner register

check the configuration file of gitlab-runner

[root@docker ~]# cat /var/lib/docker/volumes/gitlab-runner-config/_data/config.toml 
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "gitlab-tmp-project"
  url = "https://gitlab.com/"
  token = "GssVseaD_s_dyv342WS4"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

login to it

docker exec -it $(docker ps | grep 'gitlab\-runner' | cut -d' ' -f1) bash

go into home directory

from here you can see your pipeline output NOTE that you have set home directory ( ~ ) in your gitlab-ci.yml file

cd /home/gitlab-runner

running the whole process in one script

#!/bin/bash
# gitlab-runner with docker
# official doc
# https://docs.gitlab.com/runner/install/docker.html

# create a docker volume
docker volume create gitlab-runner-config


# run the gitlab-runner container 
docker run -d --name gitlab-runner --restart always \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v gitlab-runner-config:/etc/gitlab-runner \
    gitlab/gitlab-runner:latest


# register a project with gitlab-ruuner container ( it is in interactive mode)
docker run --rm -it -v gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner register

# check the configuration file of gitlab-runner
cat /var/lib/docker/volumes/gitlab-runner-config/_data/config.toml 

# login to it
docker exec -it $(docker ps | grep 'gitlab\-runner' | cut -d' ' -f1) bash


# go into home directory , from here you can see your pipeline output
# NOTE that you have set home directory ( ~ ) in your gitlab-ci.yml file
cd /home/gitlab-runner

screenshot of the result

the top terminal is my local machine and below that is the gitlab-runner with docker

document can be found here