In my application.yml file, I added the server port on 8080.
server:
port: 8080
Now in my Dockerfile, I am exposing port range 8080-8089. Here my goal is I will run this image on the different external and internal ports.
My Dockerfile is given bellow
FROM openjdk:8-jdk-alpine
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} user-service.jar
EXPOSE 8000-8089
ENTRYPOINT ["java","-jar","/user-service.jar"]
My docker image build command is given below:
docker image build -t user-service .
Now after building this image, my docker run command is given below:
docker run -d -p 8080:8080 -it user-service
Here, user-service is my docker image TAG. After this, I can access the app on 8080 port.
But the problem is when I run another container with port mapping -p 8081:8081, the application is running but won't access using port 8081.
My docker run command is:
docker run -d -p 8081:8081 -it user-service
Now my goal is I want to skip the application.yml server port with my external and internal port mapping in docker
Notes:
- This is .jar deployment. For WAR deployment we can easily skip the application.yml server port by server's configuration.
- I will change the port from the docker image to run container. I don't have scope to modify the application.yml file or Dockerfile after docker build
Thanks in advance