the teamcity agent doesn't see the docker when using Qodana

940 views Asked by At

I'm running the teamcity server with 2 agents, via docker, version : 2022.10.2-linux, in Windows 11 . In the agent parameters tab, I can see the docker version: 20.10.12 docker.version. It turns out that when I'm going to create a pipeline for my kotlin application (1.8), with gradle (7.6), I can't run because it has the following error: docker.server.version exists. I've searched some places on the internet but i don't know how to solve it. Could someone help?

2

There are 2 answers

0
Boris Markov On

I assume some steps of your build configuration need docker so that build configuration should be executed on agent with docker installed. Adding docker dependent steps adds implicit requirement that agent configuration parameter docker.server.version exists. This parameter is set up automatically during agent's startup if docker is available. You run your TeamCity agent in docker container but there's no docker inside that container. Basically, you have two options:

  1. You could use DIND (Docker in Docker) e.g. install docker inside TeamCity docker image. This is the easiest approach.
  2. Mount docker socket, docker binary and (if needed) docker-compose binary from host to teamcity agent container, however I'm not sure whether it works on Windows. In addition it requires some tricky mounts of agent's work and temp folders because docker steps will be executed on host outside teamcity agent container and paths to work and temp folders on host and inside the container should be equal. Example of docker-compose.yml for Linux
version: "2"

services:
  teamcity-agent:
    image: jetbrains/teamcity-agent
    restart: always
    privileged: true
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/usr/bin/docker:/usr/bin/docker"
      - "/bin/docker-compose:/bin/docker-compose"
      - "/opt/buildagent/work:/opt/buildagent/work"
      - "/opt/buildagent/temp:/opt/buildagent/temp"
      - "/opt/buildagent/conf:/opt/buildagent/conf"
2
Rodrigo Batista On

I tried both options, but to no avail. My docker compose file

version: "3.9"
services:
  teamcity_psql:
    image: "postgres:15-alpine"
    hostname: "teamcity_psql"
    container_name: "teamcity_psql"
    restart: "always"
    environment:
      POSTGRES_DB: "teamcity"
      POSTGRES_USER: "user"
      POSTGRES_PASSWORD: "***********"
    ports:
      - "5490:5432"
    volumes:
      - "teamcity_psql_data:/var/lib/postgresql/data"
    networks:
      teamcity_network:
       ipv4_address: 172.19.0.2  

  teamcity_server:
    image: jetbrains/teamcity-server:2022.10.2-linux
    hostname: "teamcity_server"
    container_name: "teamcity_server"
    restart: "always"
    ports:
      - "8111:8111"
    volumes:
      - teamcity_server_data:/data/teamcity_server/datadir
      - teamcity_server_log:/opt/teamcity/logs
    depends_on:
      - teamcity_psql
    networks:
      teamcity_network:
       ipv4_address: 172.19.0.3
  
  teamcity_agent_taurus:
    image: jetbrains/teamcity-agent:2022.10.2-linux
    hostname: "teamcity_agent_taurus"
    container_name: "teamcity_agent_taurus"
    restart: "always"
    privileged: true
    environment:
      - SERVER_URL=http://172.19.0.3:8111
      - OWN_ADDRESS=172.19.0.4
      - OWN_PORT=9090
      - AGENT_NAME=Taurus
      - DOCKER_IN_DOCKER=start
    volumes:
      - teamcity_agent_taurus_conf:/data/teamcity_agent/conf
    networks:
      teamcity_network:
       ipv4_address: 172.19.0.4
    depends_on:
      - teamcity_server
  
  teamcity_agent_virgo:
    image: jetbrains/teamcity-agent:2022.10.2-linux
    hostname: "teamcity_agent_virgo"
    container_name: "teamcity_agent_virgo"
    restart: "always"
    privileged: true
    environment:
        - SERVER_URL=http://172.19.0.3:8111
        - OWN_ADDRESS=172.19.0.5
        - OWN_PORT=9091
        - AGENT_NAME=Virgo
        - DOCKER_IN_DOCKER=start
    volumes:
      - teamcity_agent_virgo_conf:/data/teamcity_agent/conf
    networks:
      teamcity_network:
       ipv4_address: 172.19.0.5
    depends_on:
      - teamcity_server

volumes:
  teamcity_psql_data:
    name: "teamcity_psql_data"
    driver: "local"
  teamcity_server_data:
    name: "teamcity_server_data"
    driver: "local"
  teamcity_server_log:
    name: "teamcity_server_log"
    driver: "local"
  teamcity_agent_taurus_conf:
    name: "teamcity_agent_taurus_conf"
    driver: "local"
  teamcity_agent_virgo_conf:
    name: "teamcity_agent_virgo_conf"
    driver: "local"

networks:
  teamcity_network:
    name: "teamcity_network"
    driver: "bridge"
    ipam:
      config:
      - subnet: "172.19.0.0/16"
        gateway: "172.19.0.1"