簡體   English   中英

如何使用 gitlab-runner exec docker 正確

[英]How to use gitlab-runner exec docker correclty

我正在嘗試在本地運行 gitlab 管道作業以進行測試和調試。 這是我所做的

  1. 在我的本地機器上安裝了 gitlab-runner。
  2. sudo gitlab-runner exec docker --docker-privileged --builds-dir /tmp/builds --docker-volumes /home/fox/Work/docker/core-application:/core-application Rspec

這給

Runtime platform arch=amd64 os=linux pid=632331 revision=8fa89735 version=13.6.0
Running with gitlab-runner 13.6.0 (8fa89735)
Preparing the "docker" executor
Using Docker executor with image docker:19.03.6 ...
Starting service docker:19.03.6-dind ...
Pulling docker image docker:19.03.6-dind ...
Using docker image sha256:a33335bfe8302f4d8a7688bc1fa539f2aba787ec724119be53adc4681702a3e7 for docker:19.03.6-dind with digest docker@sha256:a4f33d003b7ec9133c2a1ff61f4e80305b329c0fa8b753140b9ab2808f28328c ...
WARNING: Service docker:19.03.6-dind is already created. Ignoring.
Waiting for services to be up and running...

*** WARNING: Service runner--project-0-concurrent-0-aef5122f9d27e6f0-docker-0 probably didn't start properly.

Health check error:
service "runner--project-0-concurrent-0-aef5122f9d27e6f0-docker-0-wait-for-service" timeout

Health check container logs:

....
*********
Pulling docker image docker:19.03.6 ...
Using docker image sha256:6512892b576811235f68a6dcd5fbe10b387ac0ba3709aeaf80cd5cfcecb387c7 for docker:19.03.6 with digest docker@sha256:3eb67443c54436650bd4f1e97ddf9ab1797d75e15d685c791f6c6397edaa6d82 ...
Preparing environment
Running on runner--project-0-concurrent-0 via fox...
Getting source from Git repository
Fetching changes...
Initialized empty Git repository in /tmp/builds/project-0/.git/
Created fresh repository.
fatal: not a git repository: /home/fox/Work/docker/core-application/../.git/modules/core-application
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
ERROR: Failed to cleanup volumes
ERROR: Job failed: exit code 1
FATAL: exit code 1 

           

然后我嘗試用本地機器上的 gitlab-runner 鏡像來做。

docker run --name=runner --privileged -t --rm -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/.gitlab-runner/:/etc/gitlab-runner -v ${PWD}:${PWD} --workdir $PWD gitlab/gitlab-runner exec docker --builds-dir /tmp/builds/ Rspec

我明白了

Runtime platform arch=amd64 os=linux pid=7 revision=8fa89735 version=13.6.0
fatal: not a git repository: /home/fox/Work/docker/core-application/../.git/modules/core-application
WARNING: You most probably have uncommitted changes. 
WARNING: These changes will not be tested.         
fatal: not a git repository: /home/fox/Work/docker/core-application/../.git/modules/core-application
FATAL: exit status 128 

這是 gitlab 文檔所說的內容。

如果您想將 docker 執行器與 exec 命令一起使用,請在 docker-machine shell 或 boot2docker shell 的上下文中使用它。 這是正確地將您的本地目錄 map 到 Docker 容器內的目錄所必需的。

沒有例子,我用谷歌搜索了它,但在 docker+machine 和 gitlab-runner 周圍沒有任何結果。

有人可以告訴我如何正確地做到這一點嗎? 任何樣品?

謝謝。

您必須從 git 存儲庫/項目的根文件夾執行命令:

 $ ls -a
 ./
 ../
 .git/
 .gitignore
 .gitlab-ci.yml
 Makefile

 $ gitlab-runner exec docker <job_name>

您正在使用 docker 命令,因為 gitlab-runner 已經在后台使用了這些命令。 有關該命令的更多信息,請參閱$ gitlab-runner exec docker --help

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM