Teamcity Build won't run until Build Agents is configured with Docker?

浪尽此生 提交于 2019-12-22 18:45:11

问题


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.

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?

EDIT

@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

But still Teamcity is complaining with this message:

Which kinda leaves me clueless again.

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

Request Information:

My CI Server OS:

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

Running Container:

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

Container run by:

## 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

Build Step Information:


回答1:


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

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:

  • --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)

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

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)

examples

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 required because in the build step was sets linux



来源:https://stackoverflow.com/questions/55631068/teamcity-build-wont-run-until-build-agents-is-configured-with-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!