Regarding docker : JENKINS-30113

197 views
Skip to first unread message

Irfan Sayed

unread,
Oct 28, 2015, 2:25:51 AM10/28/15
to jenkins...@googlegroups.com
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

Irfan Sayed

unread,
Oct 28, 2015, 4:22:10 AM10/28/15
to jenkins...@googlegroups.com
Update: 
on the Jenkins job console log: i can see following lines:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

and while building docker image using dockerfile:

"Env": [
            "PATH=/usr/java/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "JAVA_VERSION=8u31",
            "BUILD_VERSION=b13",
            "JAVA_HOME=/usr/java/latest"
        ],

if we observe the PATH variable , they are not matching 
and i guess that's the problem which i am facing. Plugin is not exposing all the env variables ??
i am not getting how to resolve 

Jenkins master version : 1.631
cloudbeese custom docker plugin : 1.6.1

on the console log, i am getting following output which is wrong. 

+ java -version
java version "1.7.0_91"
OpenJDK Runtime Environment (rhel-2.6.2.1.el7_1-x86_64 u91-b00)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)

i should get following output:

java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_65-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

Regards,
irfan

Baptiste Mathus

unread,
Oct 28, 2015, 4:55:26 AM10/28/15
to jenkins...@googlegroups.com
Hi Irfan,

IMO, don't expect env vars be passed from Jenkins to the container. In my mind, expecting this in a Docker container is actually incorrect. Docker is about isolation and reproducibility. 
See Nicolas comment in the issue btw, he says something like that. 

Btw, IIUC, you're expecting to find the same JDK version inside the container and the one used to run Jenkins, which isn't something you can expect too.

My 2 cents

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CACGLCJbY6peRkNwR2_%2BtL%2B3X4xcoRzO%3D9fD%3DZpLKvRLHW-Bz8w%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !

Irfan Sayed

unread,
Oct 28, 2015, 10:21:13 AM10/28/15
to jenkins...@googlegroups.com
Thanks. So you are saying whatever environment variable we set as a part of dockerfile, are no longer will be available in build step ?
i am considering that build environment as docker container 

please suggest 

Regards
irfan


Jason Swager

unread,
Oct 28, 2015, 11:09:52 AM10/28/15
to Jenkins Users
Have you considered using the Docker plugin (https://wiki.jenkins-ci.org/display/JENKINS/Docker+Plugin)?  That plugin seems to be a closer fit for what you might want.  The entire slave is in a container and consequently, all the PreBuild plugins and Publisher plugins work like they would on a normal slave.

Irfan Sayed

unread,
Oct 28, 2015, 11:14:51 AM10/28/15
to jenkins...@googlegroups.com
Thanks let me try that 

--
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 jenkinsci-use...@googlegroups.com.

Pradeep Kumar Mantha

unread,
Oct 30, 2015, 9:11:51 PM10/30/15
to Jenkins Users
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:

Irfan Sayed

unread,
Oct 31, 2015, 5:40:50 PM10/31/15
to jenkins...@googlegroups.com
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
 

--
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 jenkinsci-use...@googlegroups.com.

Irfan Sayed

unread,
Nov 1, 2015, 11:06:21 AM11/1/15
to jenkins...@googlegroups.com
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
  

Jason Swager

unread,
Nov 1, 2015, 12:07:51 PM11/1/15
to Jenkins Users
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.

Irfan Sayed

unread,
Nov 2, 2015, 12:15:01 AM11/2/15
to jenkins...@googlegroups.com
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





Dockerfile.txt

nicolas de loof

unread,
Nov 2, 2015, 1:35:24 AM11/2/15
to jenkins...@googlegroups.com
Hi,

cloudbees docker custom build environment 1.6.x branch is focussing on evn issues, especially considering 
- we don't want docker host slave env to pollute the container one
- we want env defined by Docker image / Dockerfile to be available for the build
- we want buildwrappers to be able to inject new env, and extend PATH

1.6.1 you're using is obsolete from this point of view, please try 1.6.4

Irfan Sayed

unread,
Nov 2, 2015, 1:51:06 AM11/2/15
to jenkins...@googlegroups.com
Thanks Nicolas.
Let me try 1.6.4 right away and explore 
will update soon

Regards
Irfan


Irfan Sayed

unread,
Nov 2, 2015, 4:10:09 AM11/2/15
to jenkins...@googlegroups.com
Awesome !!! Thanks
It worked with 1.6.4 

Regards,
Irfan

Reply all
Reply to author
Forward
0 new messages