![](/img/trans.png)
[英]Unable to pip install in Docker image as agent through Jenkins declarative pipeline
[英]Jenkins always pull docker image from a declarative pipeline agent definition
我有一個使用agent {any}
定義的工作 Jenkins 管道。
但我想嘗試在 docker 鏡像上運行測試。 根據文檔,我可以通過以下方式做到這一點:
pipeline {
agent {
docker { image 'centos/python-27-centos7:latest' }
}
stages {
...
}
}
問題是我的 Jenkins 實例處於離線狀態,使用此配置,它會在運行項目時嘗試docker pull
圖像。
但是,我在 docker 中加載了 centos/python-27 圖像(通過docker images
可見,它可以通過docker run -i -t centos/python-27-centos7 /bin/bash
有什么方法可以在 Jenkins 中配置代理,使其不會嘗試從 Docker Hub 中pull
圖像?
您可以嘗試使用 dockerfile 代理。 如果構建映像所需的一切都是本地的,那么您就不必在線了。
pipeline {
agent {
dockerfile {
filename "someOtherDockerfile"
label "docker-nodes"
args "-v /tmp:/tmp"
}
}
stages {
...
}
您的另一個選擇可能是設置私有 docker 注冊表。 https://docs.docker.com/registry/deploying/
你應該我們兄弟姐妹而不是嵌套的容器圖像。 即嘗試通過-v /var/run/docker.sock:/var/run/docker.sock
將 docker 守護進程套接字的卷掛載到 Jenkins 容器。 這樣,您就可以訪問主機系統上可用的圖像。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.