Docker Community Forums

Share and learn in the Docker community.

Container network fails with 'docker service create' but works when started with 'docker run'

Hi All,

I’ using Docker 18.09.5 on Fedora 29 with all the latest updates installed.
The issue I’m facing is, that containers started with docker run work perfectly fine, while starting the same image using docker service create seem to makes the Docker network fail.

Here is an example:

docker run -d --name registry --publish published=5000,target=5000 registry:2

curl -vv http://localhost:5000/v2/
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 5000 (#0)
> GET /v2/ HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.61.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Length: 2
< Content-Type: application/json; charset=utf-8
< Docker-Distribution-Api-Version: registry/2.0
< X-Content-Type-Options: nosniff
< Date: Wed, 24 Apr 2019 18:45:21 GMT
< 
* Connection #0 to host localhost left intact

So far, all is good. But when I do

docker service create --name registry --publish published=5000,target=5000 registry:2
1tm3r0gdsfmremzdtm2bnpa0w
overall progress: 1 out of 1 tasks 
1/1: running   
verify: Service converged 

docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
1tm3r0gdsfmr        registry            replicated          1/1                 registry:2          *:5000->5000/tcp

Docker reports the service running and the port 5000 exposed. But when I do the curl again, it hangs forever.

curl -vv http://localhost:5000/v2/
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 5000 (#0)
> GET /v2/ HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.61.1
> Accept: */*
> 
....

Now, from what I can tell it seems that a connection to the container is established, but that the response cannot be routed back to the client somehow. I assume this because I can connect to the ports using telnet if the service is running while it fails immediately if not.

Here is the configuration of the Docker networks in case it is relevant

docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
13ef77dedd8b        bridge              bridge              local
995a6995bb19        docker_gwbridge     bridge              local
345a91e86f19        host                host                local
dbb246dc54d2        imse_default        bridge              local
voodlc38p11g        ingress             overlay             swarm
dba55f7f933f        none                null                local

The behavior is the same with other container too (e.g. nginx, Flask, …) so I assume I missed something.

Any help is very much appreciated, as I’m struggling to make this work for 2 days now and all my G**gle searches didn’t help me either.

If you need any more information, please let me know.

Cheers

Really, no one experiences similar issues? This, must mean I’m doing something really wrong or I phrased my question wrongly. Maybe someone could be kind enough and tell what I’m missing?

Thanks all!

Any update on this? I am facing the same issue with Docker EE on Windows Server 2019