Let’s assume we are going to run 3 containers:-
So, the simplified
docker-compose.yml looks like this:-
Hence, when a Jenkins job tries to pull artifacts from Nexus, the following error is thrown:
SOLUTION: ATTEMPT #1
The first attempt is to set up a link between Jenkins and Nginx with the Nginx alias pointing to the hostname, which is
The goal is when Jenkins communicate with Nexus through http://server/nexus/some/path, Nginx will handle the reverse proxy accordingly.
However, when running the containers, it halts with an error:-
SOLUTION: ATTEMPT #2
In effort to prevent the circular dependency problem, we can set up a link between Jenkins and Nexus with the Nexus alias pointing to the hostname, which is
This way, Jenkins communicate directly with Nexus through http://server:8081/nexus/some/pathand Nginx will stay out of it.
This works without problem.
However, this configuration somewhat defeats the purpose of using Nginx because while the users may access Jenkins and Nexus without specifying custom ports, Jenkins has to communicate with Nexus using port 8081.
Furthermore, this Nexus port is fully exposed in the build logs in all Jenkins jobs.
SOLUTION: ATTEMPT #3
The last attempt is to configure Nginx with the hostname as a network alias.
This time, Jenkins is able to communicate successfully with Nexus throughhttp://server/nexus/some/pathand Nginx will handle the reverse proxy accordingly.
This solution was originally published by My Shitty Code, Embracing the Messiness in Search of Epic Solutions.