I'm using Docker instances as Jenkins slaves and run my containers like
# docker run -d --name="Chewbakka" antigluk/jenkins-slave-centos7-java -labels docker-centos7-java -name "Chewbakka"
(actually, I do it using docker-jenkins-slave )
However, it doesn't make sense to keep maven local repository in every container.
It can be done using Docker Data Volumes
We can mount host's directory into any directory inside container if we specify -v argument like this:
-v /tmp/docker-m2cache:/root/.m2:rw
This will mount host's directory /tmp/docker-m2cache into container's /root/.m2
Resulting command will be
# docker run -d --name="Chewbakka" -v /tmp/docker-m2cache:/root/.m2:rw antigluk/jenkins-slave-centos7-java -labels docker-centos7-java -name "Chewbakka"
Подписаться на:
Комментарии к сообщению
(
Atom
)
Thank you!
ОтветитьУдалитьwith docker-compose, I am config like this:
project:
image: maven:3.3.3-jdk-8
container_name: project
restart: always
working_dir: /usr/src/project
volumes:
- .:/usr/src/project
- /tmp/m2:/root/.m2:rw
ports:
- "8080:8080"
command: bash -c "mvn compile && mvn ninja:run"
I am running maven with ninja framework.