Install gitlab-runner In Docker on Windows OS

Inspiration

Installation

Install Docker

Create Directory

Build docker image and run

docker run ^
  -v "%systemdrive%/Docker/gitlab-runner-home":/var/gitlab-runner-home ^
  -v /var/run/docker.sock:/var/run/docker.sock ^
  --name gitlab-runner ^
  gitlab/gitlab-runner:latest
docker run -v "%systemdrive%/Docker/gitlab-runner-home":/var/gitlab-runner-home -v /var/run/docker.sock:/var/run/docker.sock --name gitlab-runner gitlab/gitlab-runner:latest

Register a runner



How Docker Commands Translate
To GitLab Runner Commands



Interacting with Container

Running created container

docker container start gitlab-runner

Listing running container

docker container ls --all
docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                              NAMES
42e3edd6087b        gitlab/gitlab-runner:latest   "/sbin/tini -- /usr/…"   12 minutes ago      Up 12 minutes       0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp   gitlab-runner

Stop container

docker container stop gitlab-runner

Remove container

docker container rm gitlab-runner

Remove image

docker image rm gitlab/gitlab-runner:latest


Bulk removing images and containers:

Windows:

@echo off
FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm %%i
FOR /f "tokens=*" %%i IN ('docker images --format ""') DO docker rmi %%i

Linux

#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)


Sources