我创建了安装java,jenkins,jenkins-cli的docker镜像。现在我需要通过jenkins-cli传递一些参数,所以我需要启动jenkins-cli。我该怎么做?我不知道它是如何发布的。
这是我的剧本
FROM ubuntu:14.04
RUN apt update; \
apt upgrade -y; \
apt install -y default-jdk curl wget git maven nano unzip; \
apt-get clean
ENV JAVA_HOME /usr
ENV PATH $JAVA_HOME/bin:$PATH
RUN apt-get autoclean $$ apt-get clear cache
RUN apt-get -yqq update
RUN apt-get -yqq --no-install-recommends install git bzip2 curl unzip
RUN apt-get update
# copy jenkins war file to the container
ADD http://mirrors.jenkins.io/war-stable/2.107.1/jenkins.war /opt/jenkins.war
RUN chmod 644 /opt/jenkins.war
ENV JENKINS_HOME /jenkins
# configure the container to run jenkins, mapping container port 8080 to that host port
ENTRYPOINT ["java", "-jar", "/opt/jenkins.war"]
EXPOSE 8080
RUN mkdir /jenkins/
RUN echo 2.107.1 > /jenkins/jenkins.install.UpgradeWizard.state
RUN echo 2.107.1 > /jenkins/jenkins.install.InstallUtil.lastExecVersion
#jenkin-cli installation
RUN cd /tmp && curl --insecure -OL http://192.168.99.100:8080/jnlpJars/jenkins-cli.jar
ADD /tmp/jenkins-cli.jar /opt/jenkins/jenkins-cli.jar
RUN chmod 644 /opt/jenkins-cli.jar
WORKDIR /opt/jenkins
ENTRYPOINT ["java", "-jar", "jenkins-cli.jar", "-noCertificateCheck", "-noKeyAuth"]
CMD ["--help"]
这是错误:
Step 19/24 : RUN cd /tmp && curl --insecure -OL http://192.168.99.100:8080/jnlpJars/jenkins-cli.jar
---> Using cache
---> 9a6210009f84
Step 20/24 : ADD jenkins-cli.jar /opt/jenkins/jenkins-cli.jar
ADD failed: stat /mnt/sda1/var/lib/docker/tmp/docker-builder945232568/jenkins-cli.jar: no such file or directory[1]
这个错误导致我可能还有其他构建,如果我能找到最佳解决方案,我可以解决我的所有其他问题。 第二个问题是,我的脚本对于我目前的问题是对的吗?我该如何修改?
任何人都可以帮我这个..? 谢谢你提前
答案 0 :(得分:1)
您忘记了创建的/ opt / jenkins文件夹
更改
ADD http://mirrors.jenkins.io/war-stable/2.107.1/jenkins.war /opt/jenkins.war
要
RUN mkdir / opt / jenkins 添加http://mirrors.jenkins.io/war-stable/2.107.1/jenkins.war /opt/jenkins/jenkins.war
答案 1 :(得分:1)
鉴于你的cli工具可以通过简单的命令(例如cli-tool_command
)从容器中获得,这应该可行:
docker run --rm -it {container_image_name} {cli_tool_command} {cli_tool_args}