在Docker容器中启动Jenkins [英] Starting Jenkins in Docker Container

查看:1222
本文介绍了在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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆