How can I setup an official maven docker image with my own global settings.xml?

China☆狼群 提交于 2021-02-17 04:46:11

问题


I use docker for the first time in connection with GitLab CI. I am happy that GitLab does most of the work for me. I am using the official maven docker image maven:3-jdk-8 (https://hub.docker.com/_/maven/)

Now I would like to set the global settings.xml on that docker image, which contains data to my nexus server for the deploy phase.

I tried to follow this guide: Adding a directory and image in the docker image , but unfortunally I cannot connect to the bash of the docker image.

root@build:~# docker run maven:3-jdk-8 /bin/bash -it
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
root@7d62e8b066f7:/# exit

How can I add my own global settings.xml to my maven docker image?


回答1:


you can create/ build your own image using a Dockerfile extending the existing maven docker image i.e maven:3-jdk-8 in your case

And in there you can add a line something like below:-

COPY settings.xml /usr/share/maven/ref/

You can have multiple settings.xml named differently(obviously) and you can use them as per the requirements

like mvn <goal> -s /usr/share/maven/ref/settings-<somename>.xml

goal and someone being different as per the usage



来源:https://stackoverflow.com/questions/50057998/how-can-i-setup-an-official-maven-docker-image-with-my-own-global-settings-xml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!