Docker Community Forums

Share and learn in the Docker community.

Accessing a Spring Boot application running in remote docker container


(Pmandayam) #1

I have a Spring Boot web application as a Docker image running inside a Docker container on an AWS Amazon Linux ec2-instance.

Spring boot comes with an embedded tomcat container as you might know, and I have configured the application to run on port 9090 by specifying in the application.properties file.

Then in the Dockerfile, I expose the port 9090, and when I run the container I specify the port mapping to the host as: docker run --name client -p 9090:9090 ikshvaku/client

The thing is, I can access the web page when I type localhost:9090, but when I try to access the container from the outside world by specifying the ip address of the ec2 instance such as 52.23.514.502:9090 I get this error:

Note how the 404 is coming from the spring boot app and not a browser unique 404 error.


(Patrick Chanezon) #2

You want to add a rule to the security group for your ec2 instance to allow network traffic to it on this port. See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html for details.
I hope this helps.