config.xml is overwritten on first start of docker container

2,067 views
Skip to first unread message

Stefan Rademacher

unread,
Dec 19, 2016, 2:27:42 AM12/19/16
to jenkins...@googlegroups.com
Hi there,

I am currently working on a Docker image, that is derived from jenkins:alpine.
In my Dockerfile I copy a config.xml in the the reference content directory (/usr/share/jenkins/ref) and add some xml content with Ansible-XML. (The content added, is a cloud configuration for a Docker host)

After starting my container, I can see my config.xml in /var/jenkins_home for a couple of seconds.
After that, it is overwritten with a default config.xml. This seems to happen, some time during the start of the server. The problem cannot even be solved by using the filename config.xml.override, as suggested in the docs of the official docker image.

Weirdly, I can’t reproduce this error, when I start Jenkins without docker. In that case, my custom config.xml is kept as is on the first start of Jenkins.

In Jenkins.java (https://github.com/jenkinsci/jenkins/blob/3e2e01717976a1f1221874bfd576429c5c48b8a6/core/src/main/java/jenkins/model/Jenkins.java#L3015) I can’t find anything, that explains the overwriting of my config.xml.

Does anyone have an idea, why this happens?

Thanks and best regards
Stefan Rademacher

Wang Jianbao

unread,
Dec 19, 2016, 2:36:40 AM12/19/16
to jenkins...@googlegroups.com
Hi,
     I’m trying use the Publish Over CIFS Plugin to upload my android artifacts to remote shared folder,
but It is so slow that I almost cost 10min to upload 20KB data. What can I do to improve the speed?
 
Thanks a lot.

Mark Waite

unread,
Dec 19, 2016, 11:59:21 AM12/19/16
to jenkins...@googlegroups.com
Since you're adding the configuration in your Dockerfile, it should be there when the docker image is created.  Since you can see it for the first few seconds in the running image, I think that means the jenkins.sh startup process which copies from "ref" to "/var/jenkins_home" did what it was expected to do (though there is a risk you're seeing it before jenkins.sh copies in the file from ref/config.xml).

Since a change is happening after jenkins.sh has copied the ref content into the runtime location, I assume it must be something other than the jenkins.sh startup process which is replacing your modified ref/config.xml file with a different config.xml file.  However, I don't know of anything after that which could make that type of change.

Are you entirely sure that the modified file is in the /var/jenkins_home directory even after the jenkins.sh script has run?

I regularly use a modified config.xml to configure a Jenkins Docker instance, and it has worked quite well for me.  If you'd like to compare how mine is configured, you could look at https://github.com/MarkEWaite/docker/blob/lts-with-plugins/ref/config.xml .

Thanks,
Mark Waite

--
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/3CA43885-85DD-4530-9FC8-9F2465F949FD%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Stefan Rademacher

unread,
Dec 28, 2016, 10:39:01 AM12/28/16
to Jenkins Users
Thanks for your reply. I tried to narrow things down:

A simple Dockerfile, that only copies "my" config.xml to /usr/share/jenkins/ref/ works fine. The config.xml is kept unmodified as expected.
(The only thing, that is different between "my" config.xml and a default config.xml is the line <disableSignup>false</disableSignup>, which is true by default.)
FROM jenkins:alpine
COPY config
.xml /usr/share/jenkins/ref/
See https://github.com/sradi/jenkins-provisioning-problem/tree/5eea71d967cba618884aafb2b74245f75d0900e8

Adding some scripts to init.groovy.d (change number of executors and create a default user 'admin')... Still everything works as expected.
See https://github.com/sradi/jenkins-provisioning-problem/tree/12a431ccac229b3d24f5404e0aedc7d02810a8b1

Additionally run 'install-plugins.sh'... PROBLEM OCCURS: The config.xml is unexpectedly modified (disableSignup is reset to 'true').

FROM jenkins:alpine
RUN
/usr/local/bin/install-plugins.sh matrix-auth
COPY init
.groovy.d/* /usr/share/jenkins/ref/init.groovy.d/
COPY config.xml /usr/share/jenkins/ref/
See https://github.com/sradi/jenkins-provisioning-problem/tree/e073854ecd0e017d53f804c45a971399080efb46

When I only keep the plugin installation in my Dockerfile and remove any init script, the problem again, does NOT occur.
See https://github.com/sradi/jenkins-provisioning-problem/tree/d1a8b5a70016701db2559804896a77921b67ab17

Summary: As soon as I use an init script, that e. g. changes my numer of executors AND use install-plugins.sh in my Dockerfile, the problem occurs.

The problem can be reproduced, if you checkout the different commits of the repository, mentioned above, and run the following commands:
docker build --rm -t jenkinsproblem:latest .
docker run
-p 8080:8080 -p 50000:50000 -d --name jenkinsproblem_1 jenkinsproblem
# run this several times, until you see, that numExecutors is changed to '0'. If 'disableSignup' changed from 'false' to 'true' the problem is reproduced.
docker
exec jenkinsproblem_1 cat /var/jenkins_home/config.xml

Hope, anyone can help me. Is this a bug?

Thanks a lot and best regards
Stefan


Mark Waite

unread,
Dec 28, 2016, 4:48:45 PM12/28/16
to Jenkins Users
That description seems like a bug to me, though I can't see anything in the Docker scripts that helps me understand where the problem would be.  If I understand your description correctly, you need both the init.groovy.d scripts and the install-plugins.sh call before you see the problem.  The groovy scripts seem to be making standard calls to load and save configuration, and the install-plugins.sh script doesn't seem to make any changes to the root config.xml file.

I believe the https://github.com/jenkinsci/docker repository has a place for bug reports.  You probably want to submit a detailed description there, in hopes one of the maintainers is able to help.

Mark Waite

Jose Gerardo Pineda Galindo

unread,
Nov 29, 2017, 12:02:12 PM11/29/17
to Jenkins Users
I think I am late by a year jeje. But I ran into the same problem. Later I realized the config.xml was overwritten because I had other 2 groovy scripts that created a new user, then when running the container I saw those groovy scripts being executed and the config.xml file was generated, overwritting the one I copied to jenkins. So just to be sure check that you don't have a groovy script that generates security settings for the user.

Best regards,
Reply all
Reply to author
Forward
0 new messages