-1

I'm created a simple docker image with Spring Boot based on steps at https://spring.io/guides/gs/spring-boot-docker/.

Apparently the application is running normally, but I can not access it through the Browser.

To get my docker image: docker push renanshin/gs-spring-boot-docker

Here's an image of the Spring Boot of my Docker image.

Initialization of Spring Boot at my docker

  • are you using the `-p` option on docker to expose the port of your application? Here there is a simple documentation: https://spring.io/guides/gs/spring-boot-docker/ – pedrohreis Jan 16 '19 at 00:23
  • Yes, I'm used this command : docker run -t renanshin/gs-spring-boot-docker – Renan Shin Iti Jan 16 '19 at 00:29
  • 3
    I solved the problem. Not have any error with the docker process. I was trying to access by ip 127.0.0.1:8080, but using docker, I would have to use ip http://192.168.99.100:8080/. This was a silly mistake of mine. – Renan Shin Iti Jan 16 '19 at 00:34
  • You should also be able to access it on you local host. Both `localhost:port` and `127.0.0.1:port` should work. How are you running docker ? Which OS? What is your output for `docker ps ` ? – vishnu narayanan Jan 16 '19 at 05:54
  • As mentioned in this answer [How do I access a spring app running in a docker container?](https://stackoverflow.com/a/52729289/9164010), to access a Spring Boot app running in a Docker container, you should not only expose the port with `-p`, but also make sure that the Spring webapp listens to the special IP `0.0.0.0`. – ErikMD Jan 16 '19 at 19:04
  • 1
    @RenanShinIti That would suggest that you are using an old docker version, recent docker versions (even on Windows and MacOS) allow binding to 127.0.0.1. – Mark Rotteveel Jan 16 '19 at 19:22
  • @MarkRotteveel I deleted my answer since you commented first and may want to post an answer yourself: I think you're right that the OP is using the legacy distribution of "Docker toolbox" for Windows, which relies on `docker-machine`: in this case, `docker run -p 8080:8080` won't expose the service to `127.0.0.1:8080` on the Windows host, but to a different IP address. See also [this page of the online doc](https://docs.docker.com/machine/reference/ip/). – ErikMD Jan 16 '19 at 20:26
  • @ErikMD No, go ahead and undelete your answer, and feel free to include my bit of information in there if you want too. – Mark Rotteveel Jan 16 '19 at 20:32
  • @MarkRotteveel ok! thanks :) – ErikMD Jan 16 '19 at 21:12
  • @MarkRotteveel my Docker client version is 18.03.0-ce and engine version is 18.09.0. – Renan Shin Iti Jan 16 '19 at 21:31

1 Answers1

1

After looking at the screenshot provided by the OP, it seems @MarkRotteveel's comment is right.

Namely, the OP is running Docker on Windows, probably using Docker Toolbox for Windows (the legacy distribution based on docker machine), and it happens that in this case, docker run -p 8080:8080 … won't expose the service to 127.0.0.1:8080 on the Windows host, but to a different IP address.

For details, see this page of the online doc and that other page.

ErikMD
  • 13,377
  • 3
  • 35
  • 71