0

我正在尝试让 Gitlab CI 运行器与 DigitalOcean 一起使用 docker-compose 测试我的应用程序。

我想docker-compose up在 DigitalOcean 上运行测试我的应用程序。

所以它说要在 Ubuntu 14.04 上使用 Docker 创建一个新的 DigitalOcean 服务器https://about.gitlab.com/2016/04/19/how-to-set-up-gitlab-runner-on-digitalocean/

然后我需要选择一个图像在我的 .gitlab-ci.yml 文件中使用。

但我不想使用图像,我想运行 docker-compose -f ci.yml up 来开始测试。

这意味着我必须选择一个图像:例如 ubuntu 14.04,然后在该图像中安装 docker 和 docker-compose。但这有其自身的问题http://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/除了 Docker 在运行 .gitlab- 时抛出错误ci.yml:

$ docker daemon
time="2016-04-21T06:38:10.793651117Z" level=info msg="New containerd process, pid: 3765\n" 
time="2016-04-21T06:38:11.824956129Z" level=info msg="Graph migration to content-addressability took 0.00 seconds" 
time="2016-04-21T06:38:11.827302975Z" level=warning msg="Running modprobe bridge br_netfilter failed with message: modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.6-coreos/modules.dep.bin'\nmodprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.6-coreos/modules.dep.bin'\n, error: exit status 1" 
time="2016-04-21T06:38:11.828852474Z" level=warning msg="Running modprobe nf_nat failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.6-coreos/modules.dep.bin'`, error: exit status 1" 
time="2016-04-21T06:38:11.832218690Z" level=warning msg="Running modprobe xt_conntrack failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.6-coreos/modules.dep.bin'`, error: exit status 1" 
time="2016-04-21T06:38:11.867564889Z" level=fatal msg="Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain: iptables failed: iptables -t nat -N DOCKER: iptables v1.4.21: can't initialize iptables table `nat': Permission denied (you must be root)\nPerhaps iptables or your kernel needs to be upgraded.\n (exit status 3)" 

ERROR: Build failed: exit code 1

现在,如果我使用 Ubuntu 14.04 启动一个新的 DigitalOcean 服务器,然后运行相同的命令,它工作正常(可能是因为它只是 Ubuntu --> Docker,而不是 Ubuntu --> Docker --> Ubuntu --> Docker)。

问题

如何docker-compose up在不在 Docker 中运行 Docker 的情况下使用 Digital Ocean 和 Gitlab CI 运行器运行?

4

2 回答 2

1

当您在数字海洋中创建您的水滴时,请使用已安装 docker 的模板 ubuntu。

然后你应该在 droplet 中安装 docker compose yourself。

在你的 droplet 中安装并运行 gitlab runner 后,你可以注册一个带有 shell 的 runner 作为 executor。

最后一步是在你的 gitlab ci 文件中使用 docker compose。由于 shell executor 在本地运行脚本(在 gitlab runner 运行的主机中),您可以同时使用 docker 和 docker compose 您已经准备好的。

于 2016-05-27T08:00:08.123 回答
0

以下是 gitlab 上的相关文档: http ://docs.gitlab.com/ce/ci/docker/using_docker_build.html

于 2016-05-20T01:07:07.083 回答