1.[Register](https://docs.gitlab.com/runner/register/) a runner.
Select the `shell` executor. For example:
```shell
```shell
sudo gitlab-runner register -n\
sudo gitlab-runner register -n\
...
@@ -58,12 +66,10 @@ GitLab Runner then executes job scripts as the `gitlab-runner` user.
...
@@ -58,12 +66,10 @@ GitLab Runner then executes job scripts as the `gitlab-runner` user.
--description"My Runner"
--description"My Runner"
```
```
1. Install Docker Engine on server.
1. On the server where GitLab Runner is installed, install Docker Engine.
View a list of [supported platforms](https://docs.docker.com/engine/installation/).
For more information how to install Docker Engine on different systems,
check out the [Supported installations](https://docs.docker.com/engine/installation/).
1. Add `gitlab-runner` user to`docker` group:
1. Add the `gitlab-runner` user to the`docker` group:
```shell
```shell
sudo usermod -aG docker gitlab-runner
sudo usermod -aG docker gitlab-runner
...
@@ -75,7 +81,7 @@ GitLab Runner then executes job scripts as the `gitlab-runner` user.
...
@@ -75,7 +81,7 @@ GitLab Runner then executes job scripts as the `gitlab-runner` user.
sudo-u gitlab-runner -H docker info
sudo-u gitlab-runner -H docker info
```
```
You can now verify that everything works by adding`docker info` to `.gitlab-ci.yml`:
1. In GitLab, to verify that everything works, add`docker info` to `.gitlab-ci.yml`:
```yaml
```yaml
before_script:
before_script:
...
@@ -87,28 +93,30 @@ GitLab Runner then executes job scripts as the `gitlab-runner` user.
...
@@ -87,28 +93,30 @@ GitLab Runner then executes job scripts as the `gitlab-runner` user.
-docker run my-docker-image /script/to/run/tests
-docker run my-docker-image /script/to/run/tests
```
```
1. You can now use `docker` command (and **install**`docker-compose` if needed).
You can now use `docker` commands (and install `docker-compose` if needed).
When you add `gitlab-runner` to the `docker` group, you are effectively granting `gitlab-runner` full root permissions.
Learn more about the [security of the `docker` group](https://blog.zopyx.com/on-docker-security-docker-group-considered-harmful/).
By adding `gitlab-runner` to the `docker` group you are effectively granting `gitlab-runner` full root permissions.
### Use the Docker executor with the Docker image (Docker-in-Docker)
For more information please read [On Docker security: `docker` group considered harmful](https://blog.zopyx.com/on-docker-security-docker-group-considered-harmful/).
### Use Docker-in-Docker workflow with Docker executor
Another way to configure GitLab Runner for `docker` support is to
register a runner with the Docker executor and use the [Docker image](https://hub.docker.com/_/docker/)
to run your job scripts. This configuration is referred to as "Docker-in-Docker."
The second approach is to use the special Docker-in-Docker (dind)
The Docker image has all of the `docker` tools installed
[Docker image](https://hub.docker.com/_/docker/) with all tools installed
and can run the job script in context of the image in privileged mode.
(`docker`) and run the job script in context of that
image in privileged mode.
`docker-compose` is not part of Docker-in-Docker (dind). To use `docker-compose` in your
The `docker-compose` command is not available in this configuration by default.
CI builds, follow the `docker-compose`
To use `docker-compose` in your job scripts, follow the `docker-compose`
@@ -74,7 +74,7 @@ GitLab 11.4 or earlier, you can view the deprecated job definitions in the
...
@@ -74,7 +74,7 @@ GitLab 11.4 or earlier, you can view the deprecated job definitions in the
First, you need GitLab Runner configured:
First, you need GitLab Runner configured:
- For the [Docker-in-Docker workflow](../../../ci/docker/using_docker_build.md#use-docker-in-docker-workflow-with-docker-executor).
- For the [Docker-in-Docker workflow](../../../ci/docker/using_docker_build.md#use-the-docker-executor-with-the-docker-image-docker-in-docker).
- With enough disk space to handle generated Code Quality files. For example on the [GitLab project](https://gitlab.com/gitlab-org/gitlab) the files are approximately 7 GB.
- With enough disk space to handle generated Code Quality files. For example on the [GitLab project](https://gitlab.com/gitlab-org/gitlab) the files are approximately 7 GB.
Once you set up GitLab Runner, include the Code Quality template in your CI configuration:
Once you set up GitLab Runner, include the Code Quality template in your CI configuration: