How to reach running Docker containers on Debian Server from the outside via the browser?

Hello, I have created a Java web service with SpringBoot and Maven. This also works perfectly via the local host. Then I created a Docker container. This also starts locally without any problem and can be called up via localhost: 8080.

Now I have uploaded (pulled) the Docker container to a Debian server and started it there. It also starts successfully. Now I do not know how I can reach the server from the outside (other network). I have the serverip. But apparently I have to teach the Debian server somehow that the web service in the Docker container must be accessible via this IP + port. Does anyone have any idea how this works? So far, I have unfortunately found only very incomplete solutions on the Internet that have never led me to my goal.

Thank you in advance.

If I understand your question correctly, the thing you need is β€œ-p 8080:8080” (if you’re using docker run). This works like NAT, forwarding the inbound traffic on port 8080 to the same port inside the container.

You could also use β€œ-p 80:8080” to access your container on port 80 (default http). Just like NAT port forwarding on a router.

1 Like

Thanks. I try it now :slight_smile: