Home > OS >  java maven docker jib published port fails
java maven docker jib published port fails

Time:01-01

I have a mavenized springboot application which I successfully dockerized by using Docker Desktop Container

When reading deeper into port exposure there is differences between publish and expose. So far I got publish is for the exposure to the host and expose handles port access among different containers.
For example, I cannot really understand how to granularly setup this difference like having the containerized webapp (springboot-web) running on port 8080 and publish it to port 80 on the host system.

What am I missing?

(I am running everything on a Macbook with a Java 17 setup)

CodePudding user response:

Your maven command builds the container, not runs it.

You still need to explicitly map the ports, whether or not they are exposed/published in the build definition of the Docker image

docker run -p 8080:8080 image

Also, you shouldn't use IP addresses for other services in a Docker network, nor should you hard-code them as default environment variables

  • Related