Docker 使用 Team City Agent 解决 DNS 问题
Docker Compose DNS issues with Team City Agent
我有以下 docker-compose.yml 文件,其中包含一个 Team City 服务器和代理,我想 运行 在我的本地 Win 10 开发机器上使用 Docker 版本 17.06.1-ce-win24 (13025):
version: '3.1'
services:
tc_server:
image: jetbrains/teamcity-server:2017.1.2
ports:
- 8111:8111
volumes:
- teamcity_server:/data/teamcity_server/datadir
- teamcity_server_logs:/opt/teamcity/logs
tc_agent:
image: jetbrains/teamcity-agent:2017.1.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- teamcity_agent_conf:/data/teamcity_agent/conf
environment:
SERVER_URL: http://tc_server:8111
volumes:
teamcity_server:
teamcity_server_logs:
teamcity_agent_conf:
Team City 服务器和代理启动,但我在 UI 中看不到任何未经授权的代理。
我查看了 docker 日志:
tc_agent_1 | [2017-09-02 10:47:27,548] WARN - buildServer.AGENT.registration - Error while asking server for the communication protocols via URL http://tc_server:8111/app/agents/protocols. Will try all protocols: java.net.ConnectException: Connection refused Connection refused) (enable debug to see stacktrace)
tc_agent_1 | [2017-09-02 10:47:27,549] INFO - buildServer.AGENT.registration - Trying to register on server using 'polling' protocol.
tc_agent_1 | [2017-09-02 10:47:27,570] INFO - buildServer.AGENT.registration - Registration using 'polling' protocol failed: java.net.ConnectException: Connection refused (Connection refused) (enable debug to see stacktrace)
tc_agent_1 | [2017-09-02 10:47:27,570] INFO - buildServer.AGENT.registration - Trying to register on server using 'xml-rpc' protocol.
tc_agent_1 | [2017-09-02 10:47:27,581] INFO - buildServer.AGENT.registration - Registration using 'xml-rpc' protocol failed: java.net.ConnectException: Connection refused (Connection refused) (enable debug to see stacktrace)
tc_agent_1 | [2017-09-02 10:47:27,581] WARN - buildServer.AGENT.registration - Error registering on the server via URL http://tc_server:8111. Will continue repeating connection attempts.
看起来代理无法连接到服务器,但是运行执行此命令表明代理容器可以从 TC 服务器容器解析和检索(与日志警告相矛盾):
docker-compose exec tc_agent curl http://tc_server:8111/app/agents/protocols
<list><string>polling</string></list>
我尝试从 Docker-compose.yml 文件中删除 Agent 并使用 Docker 将其分开(tc_default 是容器正在使用的网络):
docker run --rm --network tc_default -e SERVER_URL=http://tc_server:8111 jetbrains/teamcity-agent:2017.1.2
这给出了之前在日志中发现的相同错误。所以我求助于使用服务器的IP地址:
docker run --rm --network tc_default -e SERVER_URL=http://172.18.0.3:8111 jetbrains/teamcity-agent:2017.1.2
这有效,特工出现在 Team City 未授权特工列表中。
这是代理的 DNS 问题还是我使用 docker-compose 网络不正确?如果可能的话,我更愿意将服务器和代理保存在一个 Docker-compose 文件中。
您的 tc_server 需要在代理之前启动。在tc_agent服务配置里面添加如下内容,保证启动顺序:
depends_on:
- tc_server
从您的服务名称中删除 _
,它应该可以工作。我最近在 python 中发现使用 http://service_name:port
无效的问题。但是使用 http://servername:port
有效
虽然 _
在许多图书馆和地方,它仍然不适用于所有人
这是对我有用的
docker-compose.yml
version: '3.8'
# Define the services/containers to be run
services:
teamcity: # name of the service
image: 'jetbrains/teamcity-server'
container_name: 'tmserver' # name of the container
restart: always
ports:
- "8111:8111" # specify the teamcity port default is 8111
volumes: # This will store the plugin setup config data.
- teamcity_data:/data/teamcity_server/datadir # Host is location /var/lib/docker/volumes/USERNAME_teamcity_data
- teamcity_data:/opt/teamcity/logs
teamcityagent: # name of the service
image: 'jetbrains/teamcity-agent'
container_name: 'tmagent' # name of the container
restart: always
volumes: # This will store the plugin setup config data. example: /var/lib/docker/volumes/developer_teamcity_agent_data/_data
- teamcity_agent_data:/data/teamcity_agent/conf # Host location /var/lib/docker/volumes/USERNAME_teamcity_agent_data
depends_on: # tells the teamcity_server to start first before the agent
- teamcity
environment: # Set environment variables aka Server url
- SERVER_URL=http://teamcity:8111/ # we use the name teamcity for the url so its a container to container connection
volumes:
teamcity_data:
teamcity_agent_data:
我有以下 docker-compose.yml 文件,其中包含一个 Team City 服务器和代理,我想 运行 在我的本地 Win 10 开发机器上使用 Docker 版本 17.06.1-ce-win24 (13025):
version: '3.1'
services:
tc_server:
image: jetbrains/teamcity-server:2017.1.2
ports:
- 8111:8111
volumes:
- teamcity_server:/data/teamcity_server/datadir
- teamcity_server_logs:/opt/teamcity/logs
tc_agent:
image: jetbrains/teamcity-agent:2017.1.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- teamcity_agent_conf:/data/teamcity_agent/conf
environment:
SERVER_URL: http://tc_server:8111
volumes:
teamcity_server:
teamcity_server_logs:
teamcity_agent_conf:
Team City 服务器和代理启动,但我在 UI 中看不到任何未经授权的代理。
我查看了 docker 日志:
tc_agent_1 | [2017-09-02 10:47:27,548] WARN - buildServer.AGENT.registration - Error while asking server for the communication protocols via URL http://tc_server:8111/app/agents/protocols. Will try all protocols: java.net.ConnectException: Connection refused Connection refused) (enable debug to see stacktrace)
tc_agent_1 | [2017-09-02 10:47:27,549] INFO - buildServer.AGENT.registration - Trying to register on server using 'polling' protocol.
tc_agent_1 | [2017-09-02 10:47:27,570] INFO - buildServer.AGENT.registration - Registration using 'polling' protocol failed: java.net.ConnectException: Connection refused (Connection refused) (enable debug to see stacktrace)
tc_agent_1 | [2017-09-02 10:47:27,570] INFO - buildServer.AGENT.registration - Trying to register on server using 'xml-rpc' protocol.
tc_agent_1 | [2017-09-02 10:47:27,581] INFO - buildServer.AGENT.registration - Registration using 'xml-rpc' protocol failed: java.net.ConnectException: Connection refused (Connection refused) (enable debug to see stacktrace)
tc_agent_1 | [2017-09-02 10:47:27,581] WARN - buildServer.AGENT.registration - Error registering on the server via URL http://tc_server:8111. Will continue repeating connection attempts.
看起来代理无法连接到服务器,但是运行执行此命令表明代理容器可以从 TC 服务器容器解析和检索(与日志警告相矛盾):
docker-compose exec tc_agent curl http://tc_server:8111/app/agents/protocols
<list><string>polling</string></list>
我尝试从 Docker-compose.yml 文件中删除 Agent 并使用 Docker 将其分开(tc_default 是容器正在使用的网络):
docker run --rm --network tc_default -e SERVER_URL=http://tc_server:8111 jetbrains/teamcity-agent:2017.1.2
这给出了之前在日志中发现的相同错误。所以我求助于使用服务器的IP地址:
docker run --rm --network tc_default -e SERVER_URL=http://172.18.0.3:8111 jetbrains/teamcity-agent:2017.1.2
这有效,特工出现在 Team City 未授权特工列表中。
这是代理的 DNS 问题还是我使用 docker-compose 网络不正确?如果可能的话,我更愿意将服务器和代理保存在一个 Docker-compose 文件中。
您的 tc_server 需要在代理之前启动。在tc_agent服务配置里面添加如下内容,保证启动顺序:
depends_on:
- tc_server
从您的服务名称中删除 _
,它应该可以工作。我最近在 python 中发现使用 http://service_name:port
无效的问题。但是使用 http://servername:port
有效
虽然 _
在许多图书馆和地方,它仍然不适用于所有人
这是对我有用的
docker-compose.yml
version: '3.8'
# Define the services/containers to be run
services:
teamcity: # name of the service
image: 'jetbrains/teamcity-server'
container_name: 'tmserver' # name of the container
restart: always
ports:
- "8111:8111" # specify the teamcity port default is 8111
volumes: # This will store the plugin setup config data.
- teamcity_data:/data/teamcity_server/datadir # Host is location /var/lib/docker/volumes/USERNAME_teamcity_data
- teamcity_data:/opt/teamcity/logs
teamcityagent: # name of the service
image: 'jetbrains/teamcity-agent'
container_name: 'tmagent' # name of the container
restart: always
volumes: # This will store the plugin setup config data. example: /var/lib/docker/volumes/developer_teamcity_agent_data/_data
- teamcity_agent_data:/data/teamcity_agent/conf # Host location /var/lib/docker/volumes/USERNAME_teamcity_agent_data
depends_on: # tells the teamcity_server to start first before the agent
- teamcity
environment: # Set environment variables aka Server url
- SERVER_URL=http://teamcity:8111/ # we use the name teamcity for the url so its a container to container connection
volumes:
teamcity_data:
teamcity_agent_data: