【问题标题】:Running docker when using teamcity-docker-agent - permission denied使用 teamcity-docker-agent 时运行 docker - 权限被拒绝
【发布时间】:2017-10-18 06:31:23
【问题描述】:

我们在本地 TeamCity 服务器上使用 2017.1.5(内部版本 47175),并在 ubuntu 上使用最新的 teamcity-docker-agent。

在启动 teamcity-docker-agent 时我们添加:

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

使 docker 在容器内可用。

在 docker 容器中运行示例 gradle 构建时,由于权限问题,它无法运行 /opt/buildagent/temp/agentTmp/docker-shell-script-3687474573035166736.sh。

是否有人在 teamcity-docker-agent 中使用 docker 而没有这些问题?

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

构建日志:

[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

【问题讨论】:

  • 这方面有什么动静吗?

标签: docker teamcity


【解决方案1】:

我遇到了类似的问题。这就是目前(2017 年 3 月)为我工作的内容。

<brackets> 中的项目应替换为您的相关信息,并且实际上不应在您的终端请求中包含括号。 (即,将AGENT_NAME="<your-new-tcagent-container-name>" 替换为AGENT_NAME="my-agent-container"

为了便于阅读,我添加了换行符。您应该在粘贴到终端之前删除换行符。

您还需要确保在 Docker > 首选项 > 文件共享中的 Docker 文件共享中列出了这些目录: /Users/Volumes/private/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> 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 2021-10-18
    • 2020-08-31
    • 2021-11-05
    • 2018-04-23
    • 2020-05-18
    • 2022-01-18
    相关资源
    最近更新 更多