在Jenkins码头图像中安装捆绑器 [英] Installing bundler within Jenkins docker image
问题描述
可以在码头图像中安装红宝石,特别是 jenkins
。
我可以从可以附加到容器的文档或使用 docker exec -i -t 4e2bf4128e3e bash
。这将以 jenkins @ 4e2bf4128e3e
登录我。
但是,如果我尝试安装任何东西
apt-get install ruby 2.0.0#是的将安装rvm,这只是一个例子
/ pre>
我得到
E:无法打开锁定文件/ var / lib / dpkg / lock - 打开(13:Permission denied)
E:无法锁定管理目录(/ var / lib / dpkg /),是否root?
当我尝试
sudo apt-get install ruby 2.0.0
然后我得到code> sudo命令未找到
任何帮助赞赏
解决方案您的问题是,您可以看到在这里,詹金斯码头图像执行命令作为禁止使用apt的jenkins用户。
在 https://hub.docker.com/_/jenkins/ 您有一些文档,即安装更多工具部分,建议您这样做:
FROM jenkins
#如果我们要通过apt
安装USER root
运行apt-get update&& apt-get install -y ruby make more-things-here
用户jenkins#退回到常规jenkins用户 - 良好做法
Is it possible to install ruby within a docker image, specifically
jenkins
.I can see from the docs that you can attach to a container or use
docker exec -i -t 4e2bf4128e3e bash
. This will log me in asjenkins@4e2bf4128e3e
.But if i try and install anything
apt-get install ruby 2.0.0 # Yes will install rvm, this is just an example
I get
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
And when I try
sudo apt-get install ruby 2.0.0
Then i get
sudo command not found
Any help appreciated
解决方案The problem you have is that, as you can see here, the jenkins docker images executes commands as the jenkins user which is forbidden to use apt.
On https://hub.docker.com/_/jenkins/ you have some documentation, namely the "Installing more tools" section which advise you to do this:
FROM jenkins # if we want to install via apt USER root RUN apt-get update && apt-get install -y ruby make more-thing-here USER jenkins # drop back to the regular jenkins user - good practice
这篇关于在Jenkins码头图像中安装捆绑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!