Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Path is not mounted correctly when running Docker hooks from Docker #1387
Comments
|
the docker* hook type assume you're on the host -- changing that breaks some of our assumptions but it might be possible to implement your suggestion the call into |
|
@okainov would you be interested in working on this? |
|
@asottile I'd really like to and I have also the update for not using |
|
Is there any appetite for mounting in a similar way to jenkins, where the docker container essentially becomes transparent since it would be mounted like so:
|
|
that would be a breaking change from the current set of guarantees |
Situation:
pre-commitinside Docker.docker_imageProblem
This line mostly
pre-commit/pre_commit/languages/docker.py
Line 94 in 528c7af
Currently
pre-commitmounts the current directory to/srcand uses current directory name as mount base.However this does not work when
pre-commitis run inside the container on some mounted path already, because mount points are relative to the host, not to the container.Example:
Currently pre-commit will try to mount it as
-v /project:/src,rw,Z. Expected - to mount it as-v /opt/my_code:/srcPossible solution:
When I replaced
os.getcwd()from the code above totranslate_path(os.getcwd())wheretranslate_pathis taken from https://gist.github.com/dpfoose/f96d4e4b76c2e01265619d545b77987a, it worked perfectly. It does add extradockerpip-dependency though.See also: https://forums.docker.com/t/mounting-a-volume-not-working-with-running-docker-in-docker/25775/2