首页 文章

Gitlab CI Runner,DigitalOcean和Docker Compose

提问于
浏览
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来启动测试 .

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

$ 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) .

Question

如何使用Digital Ocean和Gitlab CI runner运行 docker-compose up 而无需在Docker中运行Docker?

2 回答

  • 0
  • 0

    在数字海洋中创建Droplet时,请使用已安装docker的模板ubuntu .

    然后你应该在Droplet中安装docker compose yourselft .

    在Droplet中安装并运行gitlab runner后,您可以注册一个带有shell作为执行程序的运行程序 .

    最后一步是在你的gitlab ci文件中使用docker compose . 由于shell执行程序在本地运行脚本(在运行gitlab runner的主机中),因此您可以使用已准备好的docker和docker compose .

相关问题