gpt4 book ai didi

docker - 启动容器 Jenkins 后,权限被拒绝

转载 作者:行者123 更新时间:2023-12-02 19:02:49 24 4
gpt4 key购买 nike

创建 Jenkins 容器时,出现以下错误。可能是什么问题呢?

jenkins_1  | touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
jenkins_1 | Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?

这是我的 docker 组成:
version: '3.7'

services:

jenkins:
image: jenkins/jenkins:lts
ports:
- 7080:8080
- 50000:50000
privileged: true
volumes:
- /tmp/jenkins-test:/var/jenkins_home

最佳答案

这在issue中进行了解释。
sudo chown 1000 /tmp/jenkins-test
如果目录已经包含文件:

sudo chown -R 1000 volume_dir

This will store the jenkins data in /your/home on the host. Ensure that /your/home is accessible by the jenkins user in container (jenkins user - uid 1000) or use -u some_other_user parameter with docker run.

You must set the correct permissions in the host before you mount volumes sudo chown 1000 volume_dir



或者你可以尝试

解决,尽管涉及酷刑。

在主机上创建一个 jenkins用户,请注意它是 uid
docker run -u <jenkins-uid> ...


Do NOT docker run -u 'jenkins' - This causes the container's own jenkins user to continue to be used. Either choose a different name on the host and pass this through or pass through the resultant uid.



您可以尝试运行的bash脚本
#!/bin/bash
mkdir $PWD/jenkins

sudo chown -R 1000:1000 $PWD/jenkins

docker run -d -p 8080:8080 -p 50000:50000 -v $PWD/jenkins:/var/jenkins_home --name jenkins jenkins

关于docker - 启动容器 Jenkins 后,权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57811147/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com