在Dockerfile中运行“From ..”docker镜像

时间:2021-07-26 21:40:53

I'm building a image that builds a Jenkins and I try to use a plugin over the Jenkins when it is running, so, I need get run Jenkins before my plugin execution.

我正在构建一个构建Jenkins的映像,我尝试在Jenkins运行时使用插件,因此,我需要在插件执行之前运行Jenkins。

I execute it like docker build -t dockerfile and the error wich I am obtaining:

我执行它像docker build -t dockerfile和我得到的错误:

jenkins.JenkinsException: Error in request: [Errno 99] Cannot assign requested address

jenkins.JenkinsException:请求中的错误:[Errno 99]无法分配请求的地址

I think the problem is when the plugin is executed it guess Jenkins is running and not.

我认为问题是当插件执行时,它猜Jenkins正在运行而不是。

FROM foxylion/jenkins
MAINTAINER Mishel Uchuari <dmuchuari@hotmail.com>

RUN /usr/local/bin/install-plugins.sh workflow-remote-loader workflow-aggregator build-pipeline-plugin

ENV JENKINS_USER replicate
ENV JENKINS_PASS replicate


USER root
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get install -y apt-utils
RUN apt-get install -y python-pip
RUN apt install -y linuxbrew-wrapper
RUN useradd someuser -m -s /bin/bash
USER someuser
RUN chmod -R 777 /home/someuser
RUN brew install libyaml
USER root
RUN apt-get install build-essential
RUN apt-get -y update && apt-get -y upgrade

RUN pip install jenkins-job-builder==2.0.0.0b2
RUN pip install PyYAML python-jenkins

RUN mkdir /etc/jenkins_jobs/
COPY jenkins_jobs.ini /etc/jenkins_jobs/
COPY scm_pipeline.yaml /etc/jenkins_jobs/
RUN jenkins-jobs --conf /etc/jenkins_jobs/jenkins_jobs.ini update /etc/jenkins_jobs/scm_pipeline.yaml

1 个解决方案

#1


0  

I had the same issue myself when using it under Docker:

在Docker下使用它时我自己也有同样的问题:

File "/src/.tox/py27/local/lib/python2.7/site-packages/jenkins_jobs/builder.py", line 124, in get_plugins_info raise e JenkinsException: Error in request: [Errno 99] Cannot assign requested address

文件“/src/.tox/py27/local/lib/python2.7/site-packages/jenkins_jobs/builder.py”,第124行,在get_plugins_info中引发JenkinsException:请求中出错:[Errno 99]无法分配请求的地址

That was caused when it tries to retrieve the list of plugins, I went overriding plugins_info to short circuit the code path:

这是因为当它试图检索插件列表时,我重写了plugins_info来短路代码路径:

jjb = JenkinsJobs(args=['test', config_dir, '-o', output_dir])
jjb.builder['plugins_info'] = []  # prevents 99 cannot assign requested address
jjb.execute()

I had the issue with python 2.7.9 on Debian Jessie. If I remember correctly that is no more an issue with a later python version eg 2.7.13 from Debian Stretch.

我在Debian Jessie上遇到了python 2.7.9的问题。如果我没记错的话,后来的python版本就不再是问题,例如来自Debian Stretch的2.7.13。

(the patch on which I encountered the issue): https://gerrit.wikimedia.org/r/#/c/380929/8/tests/test_integration.py

(我遇到问题的补丁):https://gerrit.wikimedia.org/r/#/c/380929/8/tests/test_integration.py

RUN brew install libyaml

RUN brew安装libyaml

brew is a package manager for Mac OS X. Also PyYAML gracefully skip compilation when the lib is not availble. So you probably do not need that one. And I guess it would work without installing build-essential.

brew是Mac OS X的软件包管理器。当lib不可用时,PyYAML也会优雅地跳过编译。所以你可能不需要那个。而且我想如果不安装build-essential就行。

RUN pip install jenkins-job-builder==2.0.0.0b2 RUN pip install PyYAML python-jenkins

RUN pip install jenkins-job-builder == 2.0.0.0b2 RUN pip install PyYAML python-jenkins

I am surprised you have install PyYAML and python-jenkins explicitly. Supposedly installing jenkins-job-builder should install all the dependencies (eg PyYAML and python-jenkins).

我很惊讶你明确安装了PyYAML和python-jenkins。据说安装jenkins-job-builder应该安装所有依赖项(例如PyYAML和python-jenkins)。

#1


0  

I had the same issue myself when using it under Docker:

在Docker下使用它时我自己也有同样的问题:

File "/src/.tox/py27/local/lib/python2.7/site-packages/jenkins_jobs/builder.py", line 124, in get_plugins_info raise e JenkinsException: Error in request: [Errno 99] Cannot assign requested address

文件“/src/.tox/py27/local/lib/python2.7/site-packages/jenkins_jobs/builder.py”,第124行,在get_plugins_info中引发JenkinsException:请求中出错:[Errno 99]无法分配请求的地址

That was caused when it tries to retrieve the list of plugins, I went overriding plugins_info to short circuit the code path:

这是因为当它试图检索插件列表时,我重写了plugins_info来短路代码路径:

jjb = JenkinsJobs(args=['test', config_dir, '-o', output_dir])
jjb.builder['plugins_info'] = []  # prevents 99 cannot assign requested address
jjb.execute()

I had the issue with python 2.7.9 on Debian Jessie. If I remember correctly that is no more an issue with a later python version eg 2.7.13 from Debian Stretch.

我在Debian Jessie上遇到了python 2.7.9的问题。如果我没记错的话,后来的python版本就不再是问题,例如来自Debian Stretch的2.7.13。

(the patch on which I encountered the issue): https://gerrit.wikimedia.org/r/#/c/380929/8/tests/test_integration.py

(我遇到问题的补丁):https://gerrit.wikimedia.org/r/#/c/380929/8/tests/test_integration.py

RUN brew install libyaml

RUN brew安装libyaml

brew is a package manager for Mac OS X. Also PyYAML gracefully skip compilation when the lib is not availble. So you probably do not need that one. And I guess it would work without installing build-essential.

brew是Mac OS X的软件包管理器。当lib不可用时,PyYAML也会优雅地跳过编译。所以你可能不需要那个。而且我想如果不安装build-essential就行。

RUN pip install jenkins-job-builder==2.0.0.0b2 RUN pip install PyYAML python-jenkins

RUN pip install jenkins-job-builder == 2.0.0.0b2 RUN pip install PyYAML python-jenkins

I am surprised you have install PyYAML and python-jenkins explicitly. Supposedly installing jenkins-job-builder should install all the dependencies (eg PyYAML and python-jenkins).

我很惊讶你明确安装了PyYAML和python-jenkins。据说安装jenkins-job-builder应该安装所有依赖项(例如PyYAML和python-jenkins)。