Thanks Jason.
OK. let me in detail out all steps which i carried out.
Created Dockerfile (PFA).
Created Jenkins Job which will is connected to one UNIX box (using ssh port
: 22) on which docker daemon is running

as a part of Jenkins job configuration, i choose the option "Build inside a
Docker container"
when i started the build , job builds the Dockerfile and image gets created
successfully.  further, job runs that image in container and now that image
is ready for use.
After that, when i am simply running command "java -version" as a part of
build step and that step is failing because it is not finding that version
of java which i set as a part of dockerfile.

As per your  comment (if i understand correctly), i am not starting
container, job itself builds the image from Dockerfile and start the
container. further, i don't know how to ssh to running container from the
Jenkins job itself. is there already option in Jenkins job ?
I have seen option "Start/Stop container " as a build step .. but not
getting feel of how to use it

Please suggest

Regards





On Sun, Nov 1, 2015 at 10:37 PM, Jason Swager <[email protected]> wrote:

> If you're using the Docker plugin (
> https://wiki.jenkins-ci.org/display/JENKINS/Docker+Plugin), I found the
> env vars worked fine when they were setup to be available to incoming .ssh
> connections.  That sometimes meant using a different config file within the
> container to prep the variables.
>
> A good way to test - don't start the container and use as if directly
> signed in.  Instead, start the container and SSH into it.  If the vars were
> missing then, correct the container config until they worked properly.
> Then they should start working properly as a Jenkins slave too.
>
> On Sunday, November 1, 2015 at 8:06:21 AM UTC-8, Irfan Sayed wrote:
>>
>> further update:
>> after lot of digging, i found that whatever environment variables set in
>> Dockerfile (actually in image created using this dockerfile) are not
>> available in build section using docker plugin .
>>
>> but in reality , we need these variables to be available in the build
>> section.
>> In typical use case, lets say i am installing oracle JDK 8, and in the
>> base image in dockerfile, already openjdk is installed.
>> in order to use the oracle jdk, will set the environment variable and set
>> the default jdk to oracle 8
>> I did that in Dockerfile and i am able to access java version manually if
>> i try to build the image and run in container
>>
>> however, if the same dockerfile built using docker plugin , then those
>> env variables are not available in build section
>> is it by design ??
>>
>> is there any way where we can allow these variables to be available in
>> build section ???
>>
>> Regards
>>
>>
>> On Sun, Nov 1, 2015 at 3:10 AM, Irfan Sayed <[email protected]> wrote:
>>
>>> Hello,
>>>
>>> I tried using docker plugin. I have choose the option : Pull docker
>>> image from repository
>>> I have built the entire image and pushed it to private docker registry.
>>> Using Jenkins job and i am able to pull the image.
>>>
>>> now my assumption is , whatever setting i have done while creating the
>>> image should be available / intact when i am pulling image from docker
>>> registry
>>> but , in reality , it is not happening .
>>> I have configured maven while creating image but now when i am pulling
>>> image from registry, jenkins is not able to find mvn command line
>>> now, i am not getting what is missing
>>>
>>> Manually, if i try to run that image in container, then i am getting mvn
>>> command line
>>>
>>> please help
>>>
>>> Regards
>>>
>>>
>>> On Sat, Oct 31, 2015 at 6:41 AM, Pradeep Kumar Mantha <
>>> [email protected]> wrote:
>>>
>>>> Even I see the same problem as Irfan, Here we are not expecting
>>>> environment variables from Jenkins.
>>>> We expect whatever the variables/path set in docker file to be
>>>> available to the build script. But currently the variables are being
>>>> overwritten with the jenkins build environment variables, which seems to be
>>>> incorrect.
>>>>
>>>>
>>>> On Tuesday, October 27, 2015 at 11:25:51 PM UTC-7, Irfan Sayed wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> I am using cloudbeese custom build environment plugin to create the
>>>>> build environment based on docket container
>>>>> I have created dockerfile and spawning image using container.
>>>>> In the docker file , i am installing oracle JDK and setting up path
>>>>> JAVA_HOME.
>>>>>
>>>>> However, after building docker image and executing it in docker
>>>>> container through Jenkins job, I am not getting PATH variable updated 
>>>>> which
>>>>> i set in the docker file
>>>>>
>>>>> I executed "java -version" command as a build step and it is showing
>>>>> some old version rather than the version which i set through dockerfile
>>>>>
>>>>> I feel that , the issue is similar to JENKINS-30113
>>>>>
>>>>> can someone please suggest
>>>>>
>>>>> Regards
>>>>> Irfan
>>>>>
>>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Jenkins Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/jenkinsci-users/d57820c9-db3d-4561-b3b8-dece85293e0f%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/jenkinsci-users/d57820c9-db3d-4561-b3b8-dece85293e0f%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/496cc188-1e74-47f6-a056-df34f6b19a08%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/496cc188-1e74-47f6-a056-df34f6b19a08%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CACGLCJb%2BGdSZOZJDFPP-wXgHD6Pone%3DDpQKAxwvoAtxTbnwc5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
# java
#
# VERSION       Java 8

# use the centos base image provided by dotCloud
FROM centos

ENV JAVA_VERSION 8u31
ENV BUILD_VERSION b13

# Upgrading system
RUN yum -y upgrade && yum -y install wget && yum -y install maven

# Downloading Java
RUN wget --no-cookies --no-check-certificate --header "Cookie: 
oraclelicense=accept-securebackup-cookie" 
"http://download.oracle.com/otn-pub/java/jdk/$JAVA_VERSION-$BUILD_VERSION/jdk-$JAVA_VERSION-linux-x64.rpm";
 -O /tmp/jdk-8-linux-x64.rpm

RUN yum -y install /tmp/jdk-8-linux-x64.rpm

RUN alternatives --install "/usr/bin/java" "java" "/usr/java/latest/bin/java" 2
RUN alternatives --install "/usr/bin/javaws" "javaws" 
"/usr/java/latest/bin/javaws" 2
RUN alternatives --install "/usr/bin/javac" "javac" 
"/usr/java/latest/bin/javac" 2

ENV JAVA_HOME /usr/java/latest
ENV PATH /usr/java/latest/bin:$PATH

Reply via email to