JetBrains / teamcity-docker-agent

TeamCity agent docker image sources
https://hub.docker.com/r/jetbrains/teamcity-agent/
Apache License 2.0
77 stars 64 forks source link

Permission issue when attempting to run in docker swarm #72

Closed bushshrub closed 4 years ago

bushshrub commented 4 years ago

Hi, I'm running TeamCity and TeamCity Agent in a Docker Swarm configuration and I'm seeing this error:

cp: cannot create regular file '/data/teamcity_agent/conf/buildAgent.dist.properties': Permission denied
cp: cannot create regular file '/data/teamcity_agent/conf/buildAgent.properties': Permission denied
cp: cannot create regular file '/data/teamcity_agent/conf/log4j.dtd': Permission denied
cp: cannot create regular file '/data/teamcity_agent/conf/teamcity-agent-log4j.xml': Permission denied

My compose configuration:

services:
    teamcity:
        image: jetbrains/teamcity-server:latest
        restart: on-failure
        ports:
            - "6920:8111"
        volumes:
            - "/srv/teamcity/datadir:/data/teamcity_server/datadir"
            - "/srv/teamcity/logs:/opt/teamcity/logs"
    teamcity_agent:
        image: jetbrains/teamcity-agent:2020.1.2-linux-sudo
        restart: on-failure
        volumes:
            - "/srv/teamcity_agent/conf:/data/teamcity_agent/conf"
        environment:
            - SERVER_URL="http://tc:8111"
        links:
            - "teamcity:tc"

Results of the command ls -l /srv/teamcity_agent:

total 4
drwxr-xr-x 2 root root 4096 Aug 10 11:53 conf

Any idea what could be causing this? TeamCity Server seems to be running fine so far

kir commented 4 years ago

Looks like it is a bug for initial agent startup, when it tries to generation default configuration. This happens when /srv/teamcity_agent/conf/ does not contain buildAgent.properties file. Please try changing permissions for the /srv/teamcity_agent/conf/ directory to user buildagent (id: 1000).

bushshrub commented 4 years ago

Should I be doing this within the container or on the volume I have mounted to it?

bushshrub commented 4 years ago

To add on, I'm running docker as sudo, and ls -l on /srv/ tells me that the folder is owned by root:docker and has file permissions 770. I'm executing docker as sudo.

kir commented 4 years ago

On the host system, /srv/teamcity_agent/conf/ should be writable by buildagent user. You're mounting it in your docker compose file: /srv/teamcity_agent/conf:/data/teamcity_agent/conf

bushshrub commented 4 years ago

Got it working, thanks for the help.

JarFiles commented 4 years ago

How did you fix it? Having the same problem here

bushshrub commented 4 years ago

I went into the docker container and manually changed the permissions. This can probably be automated with a pre run shell script.

olegtarasenko commented 3 years ago

Fix. Like @kir already wrote, on your host (not container) system you need to give permission for builagent user because it simply doesn't have the required one for cp operation. chmod -R 777 <mounting dir>

bushshrub commented 3 years ago

775 might be safer

On 17 Oct 2020, at 7:58 PM, Oleg notifications@github.com wrote:

 Fix. Like @kir already wrote, on your host system you need to give permission for builagent user because it simply doesn't have the required one for cp operation. chmod -R 777

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

yang0916 commented 2 years ago

I'm installing teamcity agent. It doesn't create a builagent user. How can I solve it? Do you need to create the builagent user manually

NikolayPianikov commented 2 years ago

@yang0916 What docker image are you using? Please note that the actual repo is now here https://github.com/JetBrains/teamcity-docker-images