簡體   English   中英

在Jenkins Docker鏡像中安裝bundler

[英]Installing bundler within Jenkins Docker image

是否可以在docker鏡像中安裝Ruby,特別是Jenkins?

我可以從文檔中看到你可以附加到容器或使用docker exec -i -t 4e2bf4128e3e bash 這將以jenkins@4e2bf4128e3e

但是,如果我嘗試安裝任何東西

apt-get install ruby 2.0.0 # Yes will install rvm, this is just an example

我明白了

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?

當我嘗試

sudo apt-get install ruby 2.0.0

然后我sudo command not found

你遇到的問題是,正如你在這里看到的那樣,jenkins docker圖像作為jenkins用戶執行命令,禁止使用apt。

https://hub.docker.com/_/jenkins/上有一些文檔,即“安裝更多工具”部分,建議您這樣做:

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

您可以創建自己的圖像,將這兩個圖像分層

Dockerfile

FROM jenkins
FROM ruby
...

現在你有一個自己的docker容器,它同時包含ruby和jenkins。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM