0

I'm a newbie to CI and TeamCity.
I have run TeamCity server and agent with Docker, using docker-compose.

version: "3.7"
services:
  server:
    image: jetbrains/teamcity-server:latest
    ports:
      - "8111:8111"
    volumes:
      - C:\TeamCity\server\data:/data/teamcity_server/datadir
      - C:\TeamCity\server\logs:/opt/teamcity/logs
  agent:
    image: jetbrains/teamcity-agent:latest
    environment:
      - SERVER_URL=http://server:8111
    volumes:
      - C:\TeamCity\agent\conf:/data/teamcity_agent/conf
      - C:\TeamCity\agent\logs:/opt/buildagent/logs
      - /var/run/docker.sock:/var/run/docker.sock

I have set the TeamCity server to do some build steps, including a build step that pushes a Docker image on an Azure Container Registry.
When the pipeline starts the agent tries to connect to the registry (the connection is working server side) but I get this error:

Cannot login to registry xxx.azurecr.io
An error occurred while executing 'docker login -u "TeamCity" --password-stdin xxx.azurecr.io':
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/auth": dial unix /var/run/docker.sock: connect: permission denied

Reading on the web, including similar SO questions to mine, I found that the problem seems to be that the agent is not in the docker group.

I'm running on Windows and all the answers, including the official guide of TeamCity, do examples on Linux. Anyway, I tried my best.

I entered the agent docker with docker exec -it teamcity-agent-1 /bin/bash and seems to be already in the docker group. cat etc/group --> docker:x:999:buildagent
Here is the SO question with this solution.

I also tried to add teamcity.docker.use.sudo=true in the configuration file of the agent as the official guide suggests, but then the server does not recognize the agent as a suitable agent with Docker installed.

Any suggestions?

User
  • 806
  • 1
  • 11
  • 28

1 Answers1

0

I fixed the problem adding user: root in my docker-compose.yaml as suggested in this thread

User
  • 806
  • 1
  • 11
  • 28