Running TeamCity server on Windows and agent in Docker

Hello, I've been having trouble connecting the TeamCity agent to the server. Here's my setup: TeamCity server is running as a service on my Windows 10 laptop (running on 172.20.7.154:8111), and I have a Windows Container based on the teamcity-agent:2018.1.1 image. Unfortunately the image doesn't appear on the server's "Unauthorized" list at all, and the logs keep saying that it timed out. I have uploaded the server and agent logs for clarity on the uploads.services.jetbrains.com webpage (they're called teamcity-agent.log and teamcity-server.log, I am not quite sure if I'm using this right so apologies for any confusion, I can reupload if needed). I would really appreciate it if anyone has any ideas on how to solve the problem, as I've been struggling with this for a few days, and I cannot find any resources online on combining a local server with a docker agent.

Here's the command I use to run my container, "external" is the name of a transparent network I've set up with Hyper-V:

docker run --rm -it --name teamcity-agent -v C:/ProgramData/TeamCity/agent/conf:C:/BuildAgent/conf -v C:/ProgramData/TeamCity/agent/logs:C:/BuildAgent/logs -e SERVER_URL="172.20.7.154:8111" -e AGENT_NAME="ContainerAgent" --network=external jetbrains/teamcity-agent:2018.1.1

My computer and the agent can both ping each other, so I think the network's setup correctly. As you can see I am able to ping the server IP when I execute powershell inside the container:

PS C:\> ping host.docker.internal

Pinging host.docker.internal [172.20.7.154] with 32 bytes of data:
Reply from 172.20.7.154: bytes=32 time<1ms TTL=128
Reply from 172.20.7.154: bytes=32 time<1ms TTL=128
Reply from 172.20.7.154: bytes=32 time<1ms TTL=128
Reply from 172.20.7.154: bytes=32 time<1ms TTL=128

Ping statistics for 172.20.7.154:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
PS C:\> ping 172.20.7.154

Pinging 172.20.7.154 with 32 bytes of data:
Reply from 172.20.7.154: bytes=32 time<1ms TTL=128
Reply from 172.20.7.154: bytes=32 time<1ms TTL=128
Reply from 172.20.7.154: bytes=32 time=1ms TTL=128
Reply from 172.20.7.154: bytes=32 time<1ms TTL=128

Ping statistics for 172.20.7.154:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

However when I try to manually send an HTTP request to the TeamCity server, it times out, and I think this is also what happens to the running agent when it tries to connect:

PS C:\> iwr 172.20.7.154:8111
iwr : An error occurred while sending the request.
At line:1 char:1
+ iwr 172.20.7.154:8111
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Method: GET, Re...1.14393.1000}:HttpRequestMessage) [Invoke-WebRequest], HttpRequestException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

On another note, when I try to iwr <agent-ip>:9090 from my computer, this is what pops up in the agent logs:

[2018-08-28 14:47:51,817]   WARN -    jetbrains.buildServer.AGENT - Rejecting xml-rpc connection from /172.20.7.154
[2018-08-28 14:47:51,832]  DEBUG -    jetbrains.buildServer.AGENT - Rejecting xml-rpc connection from /172.20.7.154

I have also opened the port 8111 on my laptop's firewall for all inbound connections but that doesn't seem to help

PS C:\> netsh advfirewall firewall show rule name="Open Port 8111"

Rule Name:                            Open Port 8111
----------------------------------------------------------------------
Enabled:                              Yes
Direction:                            In
Profiles:                             Domain,Private,Public
Grouping:
LocalIP:                              Any
RemoteIP:                             Any
Protocol:                             TCP
LocalPort:                            8111
RemotePort:                           Any
Edge traversal:                       No
Action:                               Allow
Ok.

Not sure what is the source of the problem here. Just to clarify I have also tried doing this using the default nat network instead of a transparent one (including mapping the container port 9090 to localhost:9090) but it's pretty much exactly the same with the exception that pinging the server from within the agent sometimes fails.

If you need more information please let me know and I'll try to provide them.

0
3 comments

Hi,

I don't think that the logs you've sent will be of any help, and for the next time, the http form uploads it to our ftp server, where we receive lots of files, so it would be more useful if you could archive them in a zip or similar file and and give it a more unique name, then reference it so that we can pull it easier.

Regarding the issue itself, first of all, after starting the server, make sure that you access it from a machine that actually has access (such as the laptop itself). You will need to finish the initial installation steps in the UI. Once you have finished the setup, try again. I'm not sure this has been the issue, as this isn't a scenario we often try, but it would be important to accept the ToS before the server actually responds to requests. If it still doesn't work, I'd suggest dropping the firewall entirely and making sure no other third party tools (such as antivirus) are blocking the connection. If it still doesn't work, please report back. If it does, then the issue is very likely on the firewall configuration.

1
Avatar
Permanently deleted user

Hello Denis,

Thanks for the reply! I understand, I'll make sure to make the files more explicit in the future.

As for the server, I did accept the ToS and had it running in the browser. I suppose it makes sense if it's the company firewall causing issues, but there's not much I can do about that. I guess the best option is just to try a different setup. I originally tried having both the server and agent running as containers, unfortunately the server would keep running out of memory which is why we tried this service + Docker setup in the first place, I think I will go back to that one and try to make it work.

Thank you for your time.

0

A quick comment on the server running out of memory issue. If the server is running out of memory, unless you set a very small amount for the image, it's likely that it's a problem with the configuration. More information on TeamCity's memory settings here: https://confluence.jetbrains.com/display/TCD18/Installing+and+Configuring+the+TeamCity+Server#InstallingandConfiguringtheTeamCityServer-SettingUpMemorysettingsforTeamCityServer

 

Java applications' memory usage is based on how much memory you provide to the JVM upon starting it. It doesn't depend (assuming it's less than the total) on the total amount of memory on the server itself, so if you are running out of memory it's very likely that the JVM is running out of its allocated memory, rather than the server itself running out of memory.

0

Please sign in to leave a comment.