Gitlab运行程序未执行作业Docker映像

时间:2018-11-29 16:55:08

标签: docker gitlab gitlab-ci-runner

我创建了一个最小的gitlab CI脚本来验证此错误:

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执行时的输出是这样的:

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容器的内容。为什么未创建容器?我在这里想念什么?

1 个答案:

答案 0 :(得分:0)

事实证明,gitlab-runner正在按预期工作。但是,令人相当困惑的是,它对正在启动的映像进行了一些操作。 入口点将被覆盖,并且将检出存储库的文件夹安装到容器中,而WORKDIR指向该文件夹。

因此,虽然可以将自己的图像作为容器运行,但要记住,在运行任何命令之前可能需要更改文件夹。