Well, Basically I wanna create a Symbolic link "ln -s" from my host to my container.
To sum up: the host folder .m2 of the host must have a Symbolic link to the .m2 folder inside my container, something like: $ ln -s containerIp:/root/.m2 myContainerAlias
I've seen the below posts but they didn't help me since I don't wanna copy the files to my local host.
Docker - copy file from container to host
Apache in Docker says: Symbolic link not allowed
https://omarabid.com/symlink-to-a-mounted-volume-in-docker/
Edited:
I've found another valuable Issue here:
How to mount a directory in the docker container to the host?
Thanks...
If you want to share data between the host and a container, or visa versa, you need to use a docker volume.
There are many ways to do this, but for your situation the easiest is to mount a host directory as a data volume. This is done with the -v
flag with docker. For example docker run -it -v /path/to/.m2:/root/.m2 ubuntu:latest /bin/bash
will run the ubuntu:latest
image with the host directory /path/to/.m2
'symlinked' to the container directory /root/.m2
.
Hope that helps.
Sounds like you're trying to optimize a Maven build running inside a container?
docker run -it --rm -w /opt/maven \
-v $PWD:/opt/maven \
-v $HOME/.m2:/root/.m2 \
maven:3.3-jdk-8 \
mvn clean install
Example
- How to build a docker container for a java app
For further investigation about this question. I would like to notify that I've "solved" my issue with the same approach than @Kai Hofstetter in the following post: How to mount a directory in the docker container to the host?