Setting up Gitlab CI (I): docker+gitlab-runner
A brief introduction about how to setup Gitlab CI (part I).
If you are new to docker, this post might help: Click this
Install and setup gitlab runner
1 | # Install gitlab runner docker image |
If you have installed gitlab-runner binary, you also can do register by one single command:
1 | sudo gitlab-runner register \ |
Prepare your docker image as CI environment
Docker images can be built from a local Dockerfile:
1 | docker build -t ${image_name}:${version_number} . |
There is a “.” at the end, don’t forget it.
Create local docker hub
Normally you can deploy your image to dockerhub.com. But if you don’t want to open your images to public, you also can create a local docker hub instead:
1 | docker run -d -p 5000:5000 --restart=always --name registry registry:2 |
After that gitlab-runner can “download” your images from localhost:5000/${image_name}.
You also can do a quick check if your image repo exist or not by accessing catalog:
1 | curl http://localhost:5000/v2/_catalog |
To be continued…