Docker and Spring boot: how to hide port from url?
I try to deploy my Spring Boot on DigitalOcean. I built docker image and run it on server and everything is fine (
docker run -p 8080:8080 hub_user/docker_image). I have my own domain and ip address (access url to my application is
myapp.com:8080). But how I can hide port number from url to access my application? How I can use my domain without port
2 Solutions collect form web for “Docker and Spring boot: how to hide port from url?”
If you are using http, what I suppose, the default port is the 80. So if you write
myapp.com is equivalent to
docker run -p 80:8080 hub_user/docker_image
This isn’t really a docker question per se. As AxelWass says, port 80 is the default port that HTTP uses (browsers automatically try and go here when you visit your site
myapp.com). Your application is actually running inside the container on port 8080, so if you just map
8080:8080 then docker will forward traffic coming to your host on port
8080 (the first one) to
8080 (the second one) inside your container.
Now, if you want traffic coming to the server on port 80 (which all web traffic will by default) to be forwarded to your container, you need to map it like