Gitlab运行程序未执行作业Docker映像 [英] Gitlab runner not executing jobs docker image
问题描述
我创建了一个最小的gitlab CI脚本来验证此错误:
I created a minimal gitlab CI script to verify this error:
docker_execution_test:
image: debian:9
script:
- pwd
- ls
我期望的输出是这样:
db@theia:~/git/docker_test (master*)$ docker run -it --rm debian:9 pwd
/
db@theia:~/git/docker_test (master*)$ docker run -it --rm debian:9 ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
但是通过gitlab-runner执行时的输出是这样的:
However, the output when executed through gitlab-runner is this:
db@theia:~/git/docker_test (master)$ gitlab-runner exec docker docker_execution_test
Runtime platform arch=amd64 os=darwin pid=49585 revision=3afdaba6 version=11.5.0
WARNING: You most probably have uncommitted changes.
WARNING: These changes will not be tested.
Running with gitlab-runner 11.5.0 (3afdaba6)
Using Docker executor with image debian:9 ...
Pulling docker image debian:9 ...
Using docker image sha256:4879790bd60d439cfe39c063660eef7af525d5f6f1cbb701a14c7cfc11cbfcf7 for debian:9 ...
Running on runner--project-0-concurrent-0 via theia.local...
Cloning repository...
Cloning into '/builds/project-0'...
done.
Checking out bb973ec4 as master...
Skipping Git submodules setup
$ pwd
/builds/project-0
$ ls
README.md
Job succeeded
该作业列出的内容是在整个过程中使用的特殊gitlab容器的内容构建。为什么未创建容器?
What the job is listing is the content of the special gitlab container that's used throughout the build. Why is the container not created? What am I missing here?
推荐答案
事实证明,gitlab-runner可以正常工作。不过,令人困惑的是,它会对启动的映像进行了一些操作。
入口点将被覆盖,将检出存储库的文件夹安装到容器中,并指向WORKDIR。
As it turns out, gitlab-runner was working as expected. What is quite confusing though is that it does some manipulations to the image it's booting up. The entrypoint is overridden and the folder the repository is checked out into is mounted into the container with the WORKDIR pointing to it.
因此,尽管将自己的图像作为容器运行,必须记住,在运行任何命令之前可能需要更改文件夹。
So while it is possible to run your own images as containers, you have to keep in mind that you might need to change the folder before running any commands.
这篇关于Gitlab运行程序未执行作业Docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!