简体   繁体   中英

Running docker when using teamcity-docker-agent - permission denied

We are using 2017.1.5 (build 47175) on a our local TeamCity server and are using the latest teamcity-docker-agent for ubuntu.

When starting the teamcity-docker-agent we add:

-v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker

to make docker available inside the container.

When running an example gradle build executed within an docker container it fails to run /opt/buildagent/temp/agentTmp/docker-shell-script-3687474573035166736.shdue to permission problems.

Is anyone using docker inside the teamcity-docker-agent without these problems?

root@99decd9a0703:/# ll /opt/buildagent/temp/agentTmp/docker-shell-script-3687474573035166736.sh

-rw-r--r-- 1 root root 225 Oct 18 06:08 /opt/buildagent/temp/agentTmp/docker-shell-script-3687474573035166736.sh

Build log:

[06:08:17][Step 1/1] Starting: /bin/sh -c docker pull openjdk && docker run --rm -w /opt/buildagent/work/472d663c385d6aef -v /opt/buildagent/work/472d663c385d6aef:/opt/buildagent/work/472d663c385d6aef -v /opt/buildagent/temp/agentTmp:/opt/buildagent/temp/agentTmp -v /opt/buildagent/temp/buildTmp:/opt/buildagent/temp/buildTmp -v /opt/buildagent/system:/opt/buildagent/system -v /opt/buildagent/lib:/opt/buildagent/lib:ro -v /opt/buildagent/tools:/opt/buildagent/tools:ro -v /opt/buildagent/plugins:/opt/buildagent/plugins:ro --env-file /opt/buildagent/temp/agentTmp/docker-wrapper-3086677386325386164.env --entrypoint /bin/sh openjdk /opt/buildagent/temp/agentTmp/docker-shell-script-3687474573035166736.sh
[06:08:17][Step 1/1] in directory: /opt/buildagent/work/472d663c385d6aef
[06:08:17][Step 1/1] Using default tag: latest
[06:08:19][Step 1/1] latest: Pulling from library/openjdk
[06:08:19][Step 1/1] Digest: sha256:9745ed74401b23fb845b4eb7ae07ecb7dc2d40bece6bdb089975a20f76766401
[06:08:19][Step 1/1] Status: Image is up to date for openjdk:latest
[06:08:20][Step 1/1] /bin/sh: 0: Can't open /opt/buildagent/temp/agentTmp/docker-shell-script-3687474573035166736.sh
[06:08:20][Step 1/1] Process exited with code 127
[06:08:20][Step 1/1] Process exited with code 127
[06:08:20][Step 1/1] Step Gradle failed

I was having similar problems. This is what is currently (March 2017) working for me.

Items in <brackets> should be replaced with your relevant info and should not actually include brackets in your Terminal request. (ie, replace AGENT_NAME="<your-new-tcagent-container-name>" with AGENT_NAME="my-agent-container"

I added line breaks for readability. You should remove line breaks before pasting into Terminal.

You also need to make sure you have these directories listed in your Docker File Sharing in Docker > Preferences > File Sharing: /Users , /Volumes , /private , and /tmp

docker run -it --name <your-new-tcAgent-CONTAINER-name>
-e SERVER_URL="<your-local-tcServer-CONTAINER-name>:8111" 
-e AGENT_NAME="<your-new-tcAgent-name-to-appear-in-tcserver>" 
-v /var/run/docker.sock:/var/run/docker.sock 
-v /opt/buildagent/work:/opt/buildagent/work 
-v /opt/buildagent/temp:/opt/buildagent/temp 
-v </where/you/wanna/store/local/configs>:/data/teamcity_agent/conf 
--link <your-local-tcServer-container-name>
<name-of-tcAgent-IMAGE-you-are-using> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM