github.com/ssube/gitlab-ci-multi-runner@v1.2.1-0.20160607142738-b8d1285632e6/docs/install/docker.md (about) 1 ## Run gitlab-runner in a container 2 3 ### Docker image installation and configuration 4 5 Install Docker first: 6 7 ```bash 8 curl -sSL https://get.docker.com/ | sh 9 ``` 10 11 We need to mount a config volume into our gitlab-runner container to 12 be used for configs and other resources: 13 14 ```bash 15 docker run -d --name gitlab-runner --restart always \ 16 -v /srv/gitlab-runner/config:/etc/gitlab-runner \ 17 gitlab/gitlab-runner:latest 18 ``` 19 20 OR you can use a config container to mount your custom data volume: 21 22 ```bash 23 docker run -d --name gitlab-runner-config \ 24 -v /etc/gitlab-runner \ 25 busybox:latest \ 26 /bin/true 27 28 docker run -d --name gitlab-runner --restart always \ 29 --volumes-from gitlab-runner-config \ 30 gitlab/gitlab-runner:latest 31 ``` 32 33 If you plan on using Docker as the method of spawning runners, you will need to 34 mount your docker socket like this: 35 36 ```bash 37 docker run -d --name gitlab-runner --restart always \ 38 -v /var/run/docker.sock:/var/run/docker.sock \ 39 -v /srv/gitlab-runner/config:/etc/gitlab-runner \ 40 gitlab/gitlab-runner:latest 41 ``` 42 43 Register the runner: 44 45 ```bash 46 docker exec -it gitlab-runner gitlab-runner register 47 48 Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci ) 49 https://gitlab.com/ci 50 Please enter the gitlab-ci token for this runner 51 xxx 52 Please enter the gitlab-ci description for this runner 53 my-runner 54 INFO[0034] fcf5c619 Registering runner... succeeded 55 Please enter the executor: shell, docker, docker-ssh, ssh? 56 docker 57 Please enter the Docker image (eg. ruby:2.1): 58 ruby:2.1 59 INFO[0037] Runner registered successfully. Feel free to start it, but if it's 60 running already the config should be automatically reloaded! 61 ``` 62 63 The runner should is started already and you are ready to build your projects! 64 65 Make sure that you read the [FAQ](../faq/README.md) section which describes 66 some of the most common problems with GitLab Runner. 67 68 ### Update 69 70 Pull the latest version: 71 72 ```bash 73 docker pull gitlab/gitlab-runner:latest 74 ``` 75 76 Stop and remove the existing container: 77 78 ```bash 79 docker stop gitlab-runner && docker rm gitlab-runner 80 ``` 81 82 Start the container as you did originally: 83 84 ```bash 85 docker run -d --name gitlab-runner --restart always \ 86 -v /var/run/docker.sock:/var/run/docker.sock \ 87 -v /srv/gitlab-runner/config:/etc/gitlab-runner \ 88 gitlab/gitlab-runner:latest 89 ``` 90 91 **Note**: you need to use the same method for mounting you data volume as you 92 did originally (`-v /srv/gitlab-runner/config:/etc/gitlab-runner` or `--volumes-from gitlab-runner`) 93 94 ### Installing Trusted SSL Server Certificates 95 96 If your GitLab CI server is using self-signed SSL certificates then you should 97 make sure the GitLab CI server certificate is trusted by the gitlab-ci-multi-runner 98 container for them to be able to talk to each other. 99 100 The `gitlab/gitlab-runner` image is configured to look for the trusted SSL 101 certificates at `/etc/gitlab-runner/certs/ca.crt`, this can however be changed using the 102 `-e "CA_CERTIFICATES_PATH=/DIR/CERT"` configuration option. 103 104 Copy the `ca.crt` file into the `certs` directory on the data volume (or container). 105 The `ca.crt` file should contain the root certificates of all the servers you 106 want gitlab-ci-multi-runner to trust. The gitlab-ci-multi-runner container will 107 import the `ca.crt` file on startup so if your container is already running you 108 may need to restart it for the changes to take effect. 109 110 ### Alpine Linux 111 112 You can also use alternative [Alpine Linux](https://www.alpinelinux.org/) based image with much smaller footprint: 113 ``` 114 gitlab/gitlab-runner latest 3e8077e209f5 13 hours ago 304.3 MB 115 gitlab/gitlab-runner alpine 7c431ac8f30f 13 hours ago 25.98 MB 116 ``` 117 118 **Alpine Linux image is designed to use only Docker as the method of spawning runners.** 119 120 The original `gitlab/gitlab-runner:latest` is based on Ubuntu 14.04 LTS. 121 122 ### SELinux 123 124 Some distributions (CentOS, RedHat, Fedora) use SELinux by default to enhance the security of the underlying system. 125 126 The special care must be taken when dealing with such configuration. 127 128 1. If you want to use Docker executor to run builds in containers you need to access the `/var/run/docker.sock`. 129 However, if you have a SELinux in enforcing mode, you will see the `Permission denied` when accessing the `/var/run/docker.sock`. 130 Install the `selinux-dockersock` and to resolve the issue: https://github.com/dpw/selinux-dockersock. 131 132 1. Make sure that persistent directory is created on host: `mkdir -p /srv/gitlab-runner/config`. 133 134 1. Run docker with `:Z` on volumes: 135 136 ```bash 137 docker run -d --name gitlab-runner --restart always \ 138 -v /var/run/docker.sock:/var/run/docker.sock \ 139 -v /srv/gitlab-runner/config:/etc/gitlab-runner:Z \ 140 gitlab/gitlab-runner:latest 141 ``` 142 143 More information about the cause and resolution can be found here: 144 http://www.projectatomic.io/blog/2015/06/using-volumes-with-docker-can-cause-problems-with-selinux/