Docker Compose yml for Gitlab and Gitlab Runner

Docker Compose yml for Gitlab and Gitlab Runner

Get Social!
version: '3.5'
services:
  gitlab:
    image: gitlab/gitlab-ce:latest
    hostname: www.jamescoyle.net
    restart: unless-stopped
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        gitlab_rails['gitlab_shell_ssh_port'] = 8822
    ports:
      - "8000:80"
      - "8822:22"
    volumes:
      - ./config/gitlab:/etc/gitlab
      - ./data/gitlab:/var/opt/gitlab
      - ./logs:/var/log/gitlab
    networks:
      - gitlab

  gitlab-runner:
    image: gitlab/gitlab-runner:alpine
    restart: unless-stopped
    depends_on:
      - gitlab
    volumes:
      - ./config/gitlab-runner:/etc/gitlab-runner
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - gitlab

networks:
  gitlab:

Create a new directory and save the above file inside it as docker-compose.yml. You’ll need to replace the field hostname with the external URL that you’ll use to access your Gitlab instance.

mkdir gitlab
vi gitlab\docker-compose.yml

Run docker-compose up -d to fetch the images from the docker hub and create your Gitlab instance. You’ll be able to access Gitlab from a browser on port 8000 and the SSH on port 8822.


3 Comments

Brian Riggs

28-Oct-2019 at 7:30 pm

Very helpful, but how do I get the runner to register with the gitlab server?
For example, I run “docker exec -it gitlab-runner bash” and then run “gitlab-runner register” within the runner container, however, it cannot resolve the gitlab hostname that I specified in the docker-compose.yml file.

Vilda

31-Oct-2019 at 3:59 pm

You have a mistake/typo in port section. – “8822:8822” should be – “8822:22” you want the external set in ‘gitlab_shell_ssh_port’ still point to 22

    James Coyle

    1-Nov-2019 at 9:15 am

    Thanks.

Leave a Reply

Visit our advertisers

Quick Poll

How often do you change the password for the computer(s) you use?

Visit our advertisers