0

I am unable to load swagger api using Docker where as the jar file runs fine: java -jar abc.jar

My swagger api doc: http://localhost:8080/api-docs/swagger.json

Docker File

FROM openjdk:14.0.2 RUN mkdir /opt/app COPY ./build/libs/OrderManagementSystem-1.0-SNAPSHOT.jar /opt/app EXPOSE 8080 CMD ["java", "-jar", "/opt/app/OrderManagementSystem-1.0-SNAPSHOT.jar"] 

Command

docker run -p 3333:8080 order-price 

I am unable to load the page http://localhost:8080/swagger

2 Answers 2

1

it seems you are hitting the wrong URL.

it should be,

http://localhost:3333/swagger 

or

http://localhost:3333/api-docs/swagger.json 

when you are binding ports while running docker, it is docker run -p host-port:container-port

Sign up to request clarification or add additional context in comments.

3 Comments

If my jar run separately loads with localhost:8080/swagger then I am not clear why I need to change to url to swagger-ui
@coder25 in that case you don't need to change to /swagger-ui and could you please share what's the error you are getting while calling localhost:3333/swagger ?
bc873136e7c4 orders "java -jar /opt/app/…" 9 seconds ago Up 8 seconds 0.0.0.0:3333->8080/tcp wonderful_mclean I am unable to load page
0

If you run your container like that:

docker run -p 3333:8080 order-price 

You are telling docker to expose internal port 8080 to port 3333 on your host. So if you wan't to access Swagger API, you have to use :

http://localhost:3333/swagger 

If you really want to user port 8080 on your host, then you have to launch your container like that :

docker run -p 8080:8080 order-price 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.