在Docker容器中启动Jenkins

编程入门 行业动态 更新时间:2024-10-23 21:24:46
本文介绍了在Docker容器中启动Jenkins的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在Centos7的Docker容器中运行Jenkins. 我看到了詹金斯的官方文件: 首先,从Docker储存库中提取正式的jenkins映像.

I want to run Jenkins in a Docker Container on Centos7. I saw the official documentation of Jenkins: First, pull the official jenkins image from Docker repository.

docker pull jenkins

接下来,使用该映像运行一个容器,并将数据目录从该容器映射到主机;例如,在下面的示例中,容器中的/var/jenkins_home从主机上的当前路径映射到jenkins/目录. Jenkins 8080端口也以49001的身份向主机公开.

Next, run a container using this image and map data directory from the container to the host; e.g in the example below /var/jenkins_home from the container is mapped to jenkins/ directory from the current path on the host. Jenkins 8080 port is also exposed to the host as 49001.

docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins

但是当我尝试运行docker容器时,出现以下错误:

But when I try to run the docker container I get the following error:

/usr/local/bin/jenkins.sh: line 25: /var/jenkins_home/copy_reference_file.log: Permission denied

有人可以告诉我如何解决此问题吗?

Can someone tell me how to fix this problem?

推荐答案

Jenkins官方Docker映像文档关于容量:

The official Jenkins Docker image documentation says regarding volumes:

docker run -p 8080:8080 -p 50000:50000 -v /your/home:/var/jenkins_home jenkins

这会将jenkins数据存储在主机上的/your/home中.确保容器中的jenkins用户(jenkins用户-uid 1000)可以访问/your/home,或者在docker run中使用-u some_other_user参数.

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.

还可以在Dockerfile中的 中找到此信息. 因此,您需要做的就是确保目录$PWD/jenkins由 UID 1000:

This information is also found in the Dockerfile. So all you need to do is to ensure that the directory $PWD/jenkins is own by UID 1000:

mkdir jenkins chown 1000 jenkins docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins

更多推荐

在Docker容器中启动Jenkins

本文发布于:2023-11-17 04:39:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608856.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容器   Docker   Jenkins

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!