How Gitlab runners work with docker image ?
I don’t undestand how gitlab runner use docker images indicate in the .gitlab-ci.yml.
# ..gitlab-ci.yml
stages:
- test
unit-test:
stage: test
image: my_repo/my_custom_image:latest
script:
- ls -al
- pwd
In the example above, I think, the runner will do something like this :
- docker pull my_repo/my_custom_image:latest
- docker run my_repo/my_custom_image:latest
- docker exec -it ID_CONTAINER /bin/sh
But with ls -al
I find that I was inside my git repository and not in a running container of my custom image.
Here is all the logs of the runner from the stage until the command ls -al
was executed :
[1]Running with gitlab-runner 14.1.0 (8925d9a0)
[2](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L2) on Definisher-API -epn6d2A
[3](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L3)Preparing the "docker" executor00:03
[4](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L4)Using Docker executor with image waphub/definisher-api:latest ...
[5](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L5)Pulling docker image waphub/definisher-api:latest ...
[6](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L6)Using docker image sha256:d8abbf6290bfcc29d08ff84e9c96b044d05cfba80f50d858413a53be7d15bd28 for waphub/definisher-api:latest with digest waphub/definisher-api@sha256:0622f166086bfcd99f652a3f41c07746ef1b438cbe2b218ce06aa3197837e9e1 ...
[8](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L8)Preparing environment00:00
[9](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L9)Running on runner--epn6d2a-project-28316369-concurrent-0 via b619526b5edc...
[11](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L11)Getting source from Git repository00:02
[12](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L12)Fetching changes with git depth set to 50...
[13](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L13)Reinitialized existing Git repository in /builds/w-ap.fr/definisher-api/.git/
[14](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L14)Checking out 09ac8e0b as developement...
[15](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L15)Skipping Git submodules setup
[17](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L17)Executing "step_script" stage of the job script00:02
[18](https://gitlab.com/w-ap.fr/definisher-api/-/jobs/1503168816#L18)Using docker image sha256:d8abbf6290bfcc29d08ff84e9c96b044d05cfba80f50d858413a53be7d15bd28 for waphub/definisher-api:latest with digest waphub/definisher-api@sha256:0622f166086bfcd99f652a3f41c07746ef1b438cbe2b218ce06aa3197837e9e1 ...
Why the image since to be use twice ? What does it mean when the runner use a docker image ?
I have found in the documentation but I didn’t find answers.
Thank you very much for your help !