I am building a custom docker image from the jenkins official image. I want to install the maven to the image and exteralize maven's config file. But I failed. After the container startup, there is a empty /etc/maven
directory. I think it may be a permission issue but I can't solve it after a half day's research. This is my docker file:
FROM jenkins
USER root
RUN apt-get update && apt-get install -y maven
What I tried then in the docker-compose.yml:
jenkins:
build: /docker/jenkins/
volumes:
- /srv/docker/jenkins:/var/jenkins_home
- /srv/docker/maven/conf:/etc/maven:rw # the rw flag has no effect!
- /srv/docker/maven/repository/:/m2:rw
I tried deleting the /srv/docker/maven
directory and let the container create it on the first time it running.
I then tried adding a VOLUME /etc/maven
instruction to the dockerfile before or after the RUN apt-get update && apt-get install -y maven
instruction. No use.
I also tried chmod ugo+wx /srv/docker/maven
but all no effects.
When you mount a host folder to docker container, it overwrites the container folder. Since the maven configuration files are created during image building, but volume is mounted at run time, volume will overwrite the conf files.
Since maven user settings overwrites global settings (see https://maven.apache.org/settings.html ), you can try mount the user settings folder instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.