Ronnie
Ronnie

Reputation: 251

How to connect to Nexus and download jar file as dependency when building a docker image of a java project

  1. I have a nexus docker container running on Port 8081, where I have deployed a JAR file.

  2. I have a simple Java + Maven project, which downloads few dependencies from the Central and this one particular JAR from Nexus. I have a customized settings.xml to download

(a) Dockerfile, which tries to builds an image

(b) Customized settings.xml

(c) pom.xml: distribution management section

enter image description here

enter image description here

enter image description here

When building (docker build -t= .), it downloads all dependencies from central, but fails to connect to the nexus and download.

enter image description here

*Note: Since everything is for learning purpose, everything is on my PC i.e localhost.

Update:

Below is the port mapping of docker containers. enter image description here

Upvotes: 3

Views: 1523

Answers (1)

Slava Kuravsky
Slava Kuravsky

Reputation: 2816

docker build runs in a separate container where there is nothing under localhost:8081. Try to build using your host network:

docker build -t imagename --network host .

Upvotes: 4

Related Questions