Skip to content

Commit 9606273

Browse files
committed
.gitlab-ci.yml documented for Docker socket binding support
1 parent aca6d16 commit 9606273

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -750,9 +750,44 @@ We also tag this runner as the `socket` one, so we can explicitly let our Jobs r
750750
The example project https://github.com/jonashackt/gitlab-ci-docker-socket-binding-example provides a fully comprehensible example on how to use the a Docker socket bound GitLab runner inside a [.gitlab-ci.yml](https://github.com/jonashackt/gitlab-ci-dind-example/blob/master/.gitlab-ci.yml):
751751

752752
```
753+
# see https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-socket-binding
754+
image: docker:stable
753755
756+
# One of the new trends in Continuous Integration/Deployment is to:
757+
# (see https://docs.gitlab.com/ee/ci/docker/using_docker_build.html)
758+
#
759+
# 1. Create an application image
760+
# 2. Run tests against the created image
761+
# 3. Push image to a remote registry
762+
# 4. Deploy to a server from the pushed image
763+
764+
stages:
765+
- build
766+
- test
767+
- push
768+
- deploy
769+
770+
# see usage of Namespaces at https://docs.gitlab.com/ee/user/group/#namespaces
771+
variables:
772+
REGISTRY_GROUP_PROJECT: $CI_REGISTRY/root/gitlab-ci-shell-example
773+
774+
# see how to login at https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#using-the-gitlab-container-registry
775+
before_script:
776+
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
777+
778+
build-image:
779+
stage: build
780+
# the tag 'shell' advices only GitLab runners using this tag to pick up that job
781+
tags:
782+
- socket
783+
script:
784+
- docker build . --tag $REGISTRY_GROUP_PROJECT/gitlab-ci-shell-example:latest
785+
786+
...
754787
```
755788

789+
There are only 2 differences to the shell runner needed here: Using `image: docker:stable` as the image for this pipeline and defining `socket` tag so that GitLab will only pick the correct Docker socket binding enabled runners for these jobs.
790+
756791

757792
### Configure .gitlab-ci.yml Jobs to run only on specific gitlab-runners
758793

0 commit comments

Comments
 (0)