I don't understand the mechanism of the keywords image
and services
in the file.gitlab-ci.yml. when do we know on which image the commands of the keyword script
are executed ?
When i read the gitlabci documentation i understand the theory of the keywords "image" and "services" well, so i have already done tests and managed to interact with a httpd
service by a wget for example, however, in practice i can't understand what the image is for ?
Let me explain :)
First i created a structure with a job that makes a "uname -a" by not declaring any images:
job_scriptWithDefaultImage:
stage: gitlabtest1
script:
- uname -a
The result then shows me a "uname -a" running on the runner:
$ uname -a
Linux runner-b41b332f-project-9060-concurrent-0 4.4.0-104-generic #127-Ubuntu SMP Mon Dec 11 12:16:42 UTC 2017 x86_64 Linux
Then i simply add an image in my job specifying i want to use an alpine:
job_scriptWithAlpineImage:
internship: gitlabtest2
image: registry.hub.docker.com/library/alpine:latest
script:
- uname -a
The result is exactly the same, the uname always runs on the runner, instead of my alpine ...
$ uname -a
Linux runner-9cade5e3-project-9060-concurrent-0 4.4.0-130-generic #156-Ubuntu SMP Thu Jun 14 08:53:28 UTC 2018 x86_64 GNU/Linux
So i don't understand at all:
script
section ?Docker uses the host's kernel. As you can see by your uname -a
output, it gives the runner's machine info. That's why regardless of the container you get the same output. You can even try it on your machine.
https://stackoverflow.com/a/31012367/4551937
Regarding Gitlab Runner, your service
is independent. It will be attached and provided to your job calling it, as if it was running beside it.
Your job will use the image you specify with the image
tag to run the commands listed in script
(you can chain them). If no image is specified, it will take the default one defined in the runner configuration (probably Ubuntu).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With