Docker Community Forums

Share and learn in the Docker community.

Docker run vs service create, network connection hanging with latter

docker

(Polypus74) #1

i have a situation in which i use the exact same image
running in docker locally, where an http request to the container
running a simple ‘hello world’ server, hangs when doing this:

docker service create --name x -p 8081:8081 image:latest

but does not hang and responds correctly when doing this:

docker run --name x -p 8081:8081 image:latest

in the first case the swarm was properly initialized.
in the second i left the swarm locally before running.
in both cases i am doing a ‘curl localhost:8081’.

in both cases my server process is periodically
writing a “heartbeat” to the logs without fail.

if i don’t run any containers curl just returns
immediately with an error, so the container must
at the very least be listening on the port because
curl just sits there.

my server is in go, and calling http.ListenAndServer(":8081", nil)

i’m running 1.12.1 on up to date arch linux

i’m new to docker so may be missing something obvious.

thanks for any tips/advice