Reputation: 63
I have Jenkins in a docker container and inside the container I have a local git repository, I added a post-commit file which runs a build in Jenkins each time a commit is made but the file doesn't run, what is the problem?
this is the post commit file (it's in the container)
Jenkins which is running inside the docker container on localhost
Upvotes: 0
Views: 2782
Reputation: 5063
I see this mistake over and over again.
localhost
is always resolved to the 127.0.0.1 of whatever machine it's used on. In context of the container 127.0.0.1 is the container itself, not the machine Docker is running on.
If both Jenkins and Git container use the same network, you can use Jenkins's container IP in your hook URL. Otherwise you need to put them on the same network first - see this question on how to do that.
Upvotes: 1