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

查看:306
本文介绍了在使用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?

编辑

@Senior 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:

还有点叶子

最终解决方案
即将重启的team2服务器实例可以解决即将出现的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

构建步骤信息:



推荐答案

TC限制了配置,因为TA无法启动Docker守护进程。

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,因此使用此风险自负)

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天全站免登陆