docs: add docker-in-docker from registry example
- use specific docker version 19.03.1 in example
This commit is contained in:
parent
ce84140e8b
commit
a3704b3657
1 changed files with 36 additions and 0 deletions
|
@ -575,6 +575,42 @@ For private and internal projects:
|
||||||
docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
|
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
|
### Container Registry examples
|
||||||
|
|
||||||
If you're using docker-in-docker on your Runners, this is how your `.gitlab-ci.yml`
|
If you're using docker-in-docker on your Runners, this is how your `.gitlab-ci.yml`
|
||||||
|
|
Loading…
Reference in a new issue