Skip to content

Instantly share code, notes, and snippets.

@Gong-Bao-Chicken
Created March 12, 2019 14:58
Show Gist options
  • Save Gong-Bao-Chicken/d90325fefbba4ba40f699a2e6672221a to your computer and use it in GitHub Desktop.
Save Gong-Bao-Chicken/d90325fefbba4ba40f699a2e6672221a to your computer and use it in GitHub Desktop.
Gitlab + Gitlab Runner on same machine using Docker & Docker compose
version: "3"
services:
gitlab:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'subdomain.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://subdomain.example.com'
letsencrypt['enable'] = true
gitlab_rails['gitlab_shell_ssh_port'] = 822 #Custom port because 22 is used otherwise
letsencrypt['auto_renew_hour'] = "3"
letsencrypt['auto_renew_minute'] = "30"
letsencrypt['auto_renew_day_of_month'] = "1"
letsencrypt['auto_renew'] = true
# for more options check gitlab documentation.
ports:
- '80:80'
- '443:443'
- '822:22' #Custom port because 22 is used otherwise
volumes:
- './gitlab/config:/etc/gitlab'
- './gitlab/logs:/var/log/gitlab'
- './gitlab/data:/var/opt/gitlab'
networks:
- backend
gitlab-runner:
image: 'gitlab/gitlab-runner:latest'
restart: always
volumes:
- './gitlab-runner/config:/etc/gitlab-runner'
- '/var/run/docker.sock:/var/run/docker.sock'
depends_on:
- gitlab
networks:
- backend
networks:
backend:
driver: bridge

Start all containers from the same folder of the docker-compose file:

docker-compose up -d 

List running containers:

docker ps 

Inspect a container to find the ip of the container for local installation:

docker inspect <container> 

Register a runner:

docker exec -it <container> gitlab-runner register

Update:

docker-compose pull # get image tagged in docker-compose.yaml
docker-compose up -d # start container 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment