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.


5 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.

Jèr Nersa

27-May-2020 at 9:35 pm

How does gitlab know about the runner? Don’t you need to specify the gitlab url to the gitlab runner?

hung

9-Jun-2020 at 4:57 pm

Did you test on the Windows?
version: ‘3.5’
services:
gitlab:
image: gitlab/gitlab-ce:latest
hostname: http://www.jamescoyle.net
restart: unless-stopped
environment:
GITLAB_OMNIBUS_CONFIG: |
gitlab_rails[‘gitlab_shell_ssh_port’] = 8822
ports:
– “8000:80”
– “8822:22”
volumes:
– E:/1/1/config:/etc/gitlab
– E:/1/1/data:/var/opt/gitlab
– E:/1/1/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:
it does not work
———————
but when i comment out the volume, it works fine.

version: ‘3.5’
services:
gitlab:
image: gitlab/gitlab-ce:latest
hostname: http://www.jamescoyle.net
restart: unless-stopped
environment:
GITLAB_OMNIBUS_CONFIG: |
gitlab_rails[‘gitlab_shell_ssh_port’] = 8822
ports:
– “8000:80”
– “8822:22”

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:

Leave a Reply

Visit our advertisers

Quick Poll

Are you using Docker.io?

Visit our advertisers