2

i have created the docker image that installs java,jenkins,jenkins-cli. now i need to pass some argument through jenkins-cli, so i need to launch jenkins-cli. How do i do it? i have no idea how it launches.

Here is my script

    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"]

this is error:

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] 

This error is causing me for may other build too,if i can find best solution i can solve my all other problems. 2nd question is, is my scripting for my current problem is right? How can i modify?

Can anyone help me with this..? thank u in advance

Hithesh
  • 113
  • 1
  • 13
  • Update: i changed the WORKDIR to /tmp Now the build is success but im unable to run. does my updation is wrong, or there any other way to Run it??????? – Hithesh Apr 06 '18 at 07:21

2 Answers2

1

You forgot to create the /opt/jenkins folder

Change

ADD http://mirrors.jenkins.io/war-stable/2.107.1/jenkins.war /opt/jenkins.war

to

RUN mkdir /opt/jenkins
ADD http://mirrors.jenkins.io/war-stable/2.107.1/jenkins.war /opt/jenkins/jenkins.war
metters
  • 533
  • 1
  • 8
  • 17
Meiram Chuzhenbayev
  • 898
  • 1
  • 10
  • 26
  • can u link me to any of related video or how to run, coz im unable to download jenkins-cli now after implementing ur suggetion – Hithesh Apr 06 '18 at 09:06
  • how can i run that image? docker run -it ? or is there diffrent way? – Hithesh Apr 06 '18 at 09:17
1

Given your cli tool is available from within your container with a simple command such as cli-tool_command this should work:

docker run --rm -it {container_image_name} {cli_tool_command} {cli_tool_args}
EddardOmeka
  • 163
  • 1
  • 6
  • C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"java\": executable file not found in $PATH": unknown. – Hithesh Apr 09 '18 at 05:50