Merge branch 'patch-15' into 'master'

docs: add docker-in-docker from registry example

See merge request gitlab-org/gitlab-ce!31101
This commit is contained in:
Evan Read 2019-08-30 03:54:53 +00:00
commit cc3c1a66dd

View file

@ -575,6 +575,42 @@ For private and internal projects:
docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
```
### Using docker-in-docker image from Container Registry
If you want to use your own Docker images for docker-in-docker there are a few things you need to do in addition to the steps in the [docker-in-docker](#use-docker-in-docker-workflow-with-docker-executor) section:
1. Update the `image` and `service` to point to your registry.
1. Add a service [alias](https://docs.gitlab.com/ee/ci/yaml/#servicesalias)
Below is an example of how your `.gitlab-ci.yml` should look like, assuming you have it configured with [TLS enabled](#tls-enabled):
```yaml
build:
image: $CI_REGISTRY/group/project/docker:19.03.1
services:
- name: $CI_REGISTRY/group/project/docker:19.03.1-dind
alias: docker
variables:
# Specify to Docker where to create the certificates, Docker will
# create them automatically on boot, and will create
# `/certs/client` that will be shared between the service and
# build container.
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_DRIVER: overlay2
stage: build
script:
- docker build -t my-docker-image .
- docker run my-docker-image /script/to/run/tests
```
If you forget to set the service alias the `docker:19.03.1` image won't find the
`dind` service, and an error like the following is thrown:
```sh
$ docker info
error during connect: Get http://docker:2376/v1.39/info: dial tcp: lookup docker on 192.168.0.1:53: no such host
```
### Container Registry examples
If you're using docker-in-docker on your Runners, this is how your `.gitlab-ci.yml`