so I created a service on a docker swarm:
docker create service --name my-service --network my-network -p 8761:8761 --replicas 1 my-image
It's a Spring Boot application and when looking at stdout of the created docker container the following line is shown:
2017-01-19 12:44:48.588 INFO 6 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8761 (http)
Indicating the application listens to the proper port.
When running docker service inspect my-service
it also says the port 8761 is published for this service.
When I then try issue: curl http://localhost:8761
(on the docker swarm master, the only node in the swarm for now) I run into a timeout. Curling to any other port results in an immediate Connection Refused
error.
The Spring Boot app works fine when started directly on the machine, there are no hints in the logs, I don't really know where to look next ... anybody a clue here?
You should curl
to the manager's IP, since it is the node in which your container is running.
You mention in your question that you're running the curl
command inside the container, but I assume you've done something like eval $("docker-machine env <manager>")
, which will only allow you to launch containers in the manager. With this you only select the active docker engine to be used.
To actually run a command in the machine you should ssh into it, and then you could curl
to localhost:
docker-machine ssh <manager> -- curl localhost:8761