在使用Docker配置Build Agents之前,Teamcity Build不会运行吗? [英] Teamcity Build won't run until Build Agents is configured with Docker?

查看:42
本文介绍了在使用Docker配置Build Agents之前,Teamcity Build不会运行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Teamcity管道创建了一个新版本.第一次使用Docker buildstep.设置完所有内容后,我意识到构建代理似乎还没有准备好.

I created a new build for my Teamcity pipeline. For the first time I use then Docker buildstep. After I setup everything I realized the build agent does not seem to be ready for it.

我了解我的经纪人似乎还没有准备好使用docker 进行构建,但是实际上没有人告诉我如何做到这一点.我阅读了官方指南,但是没有任何关于如何将docker实际安装到我的代理中的消息(如果那是解决问题的方法).

I understand that my agent does not seem to be ready for building with docker but nobody is actually telling me how you can do that. I read the official guides but no word about how to actually install docker into my agent (if that's the way to solve the problem).

有人可以告诉我要使其正常工作该怎么做吗?

Can someone tell me what I have to do to get it to work?

编辑

@高级Pomidor帮助我更进一步.我在docker run命令中添加了他的第一个示例

@Senior Pomidor helped me to get one step closer. I added his first example to the docker run command

docker run -it -e SERVER_URL="<url to TeamCity server>"  \
    --privileged -e DOCKER_IN_DOCKER=start \    
    jetbrains/teamcity-agent 

这样做之后,我摆脱了屏幕截图中提到的消息.我的代理程序配置现在具有以下内容:

After doing so I got rid of the mentioned messages in the screenshot. My Agents configuration now has the following:

docker.server.osType     linux
docker.server.version    18.06.1
docker.version   18.06.1

但是,Teamcity仍在抱怨此消息:

But still Teamcity is complaining with this message:

还有点让我一无所知.

最终解决方案:只需重新启动teamcity服务器实例,即可解决即将出现的EDIT2问题.该代理实际上可以运行该构建,但是teamcity在没有重新引导的情况下无法意识到这一点.

Final Solution: The upcoming EDIT2 issue could be resolved by just restarting the teamcity server instance. The agent was actually able to run the build but teamcity was not able to realise that without a reboot.

EDIT2

请求信息:

我的CI服务器操作系统:

My CI Server OS:

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"

正在运行的容器:

CONTAINER ID        IMAGE                       COMMAND              CREATED             STATUS              PORTS                  NAMES
0f8e0b04d6a6        jetbrains/teamcity-agent    "/run-services.sh"   19 hours ago        Up 19 hours         9090/tcp               teamcity-agent
20964c22b2d9        jetbrains/teamcity-server   "/run-services.sh"   37 hours ago        Up 37 hours         0.0.0.0:80->8111/tcp   teamcity-server-instance

容器运行者:

## Server
docker run -dit --name teamcity-server-instance  -v /data/teamcity:/data/teamcity_server/datadir -v /var/log/teamcity:/opt/teamcity/logs  -p 80:8111 jetbrains/teamcity-server

## Agent
docker run -itd --name teamcity-agent -e SERVER_URL="XXX.XXX.XXX.XXX:80"  --privileged -e DOCKER_IN_DOCKER=start -v /etc/teamcity/agent/conf:/data/teamcity_agent/conf jetbrains/teamcity-agent

构建步骤信息:

推荐答案

由于TA无法启动Docker守护程序,TC限制了配置.

TC restricted the configuration because of TA doesn't start Docker daemon.

您应该传递 -e DOCKER_IN_DOCKER = start 以自动启动容器中的docker守护程序.另外,docker守护进程需要docker套接字.在Linux容器中,如果需要内部可用的Docker守护程序,则有两个选择:

You should pass -e DOCKER_IN_DOCKER=start for automatically staring the docker daemon in the container. Also, docker daemon needs the docker socket. In a Linux container, if you need a Docker daemon available inside your builds, you have two options:

  • -特权标志.在您的容器中运行的新Docker守护程序
  • -v docker_volumes:/var/lib/docker 来自主机的Docker(在这种情况下,您将从主机和所有容器之间共享的缓存中受益,但存在安全问题:您的构建实际上可能会损害您的主机Docker,因此请您自担风险)
  • --privileged flag. New Docker daemon running within your container
  • -v docker_volumes:/var/lib/docker Docker from the host (in this case you will benefit from the caches shared between the host and all your containers but there is a security concern: your build may actually harm your host Docker, so use it at your own risk)

在Linux容器中,如果您需要内部可用的Docker守护程序,则有两个选择:

In a Linux container, if you need a Docker daemon available inside your builds, you have two options:

1)来自主机的Docker(在这种情况下,您将受益于主机与所有容器之间共享的缓存,但是存在安全方面的担忧:您的构建实际上可能会损害您的主机Docker,因此使用此风险自担风险))

1) Docker from the host (in this case you will benefit from the caches shared between the host and all your containers but there is a security concern: your build may actually harm your host Docker, so use it at your own risk)

示例

docker run -it -e SERVER_URL="<url to TeamCity server>"  \
    --privileged -e DOCKER_IN_DOCKER=start \    
    jetbrains/teamcity-agent 

docker run -it -e SERVER_URL="<url to TeamCity server>"  \
    -v /var/run/docker.sock:/var/run/docker.sock  \
    jetbrains/teamcity-agent 

UDP

docker.server.osType 是必需的,因为在构建步骤中设置了 linux

docker.server.osType required because in the build step was sets linux

这篇关于在使用Docker配置Build Agents之前,Teamcity Build不会运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆