Docker Community Forums

Share and learn in the Docker community.

Can't use bridge:port for accessing internal services

beta

(Kesselborn) #1

Expected behavior

The docker bridge exposes mapped ports within the docker network

Actual behavior

I get a ‘connection refused’

Information

$ pinata get native/port-forwarding
true
$ pinata get network
hostnet

Without the virtualbox version (and on linux), it’s possible to access docker port mappings from other containers using the bridge.
Example:

  • container1 has ip 172.19.0.7 and a service that listens on port 8080 which gets maaped to port 31249 on the bridge
  • from within another container in the same network I can access this service via 172.19.0.1:31249, i.e. using the bridge ip and the mapped port

With the beta version, this is not possible anymore, I get a connection refused instead


(Dave Tucker) #2

@kesselborn thanks for the report.

I’ve tried to reproduce the following way:

$ web=$(docker run -p 80:80 -d nginx)
$ docker run -it alpine wget -qO- http://$(docker inspect -f {{.NetworkSettings.Gateway}} $web)
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

So it seems to be working for me on the latest master build. Which version of the Beta are you running?


(Kesselborn) #3

Thanks a lot for the quick reply. I used your test case and for me the problem remains as described:

$ web=$(docker run -p 80:80 -d nginx)
$ docker run -it alpine wget -qO- http://$(docker inspect -f {{.NetworkSettings.Gateway}} $web)
wget: can't connect to remote host (172.17.0.1): Connection refused

… changing the network mode to nat does not change anything. When trying the same with virtualbox-based docker, it works.

I am running the following version:

Version 1.11.0-beta9 (build: 6388) 965e3f981d73fe82857f3c1439ba3dc1acaecab6

$ docker version  # same for beta & virtualbox docker
Client:
 Version:      1.11.0
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   4dc5990
 Built:        Wed Apr 13 19:36:04 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.11.0
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   a5315b8
 Built:        Tue Apr 26 15:23:39 2016
 OS/Arch:      linux/amd64

(Kesselborn) #4

Happy to report that with version Version 1.11.1-beta10 (build: 6662) everything works as expected, thanks!


(Dave Tucker) #5

Great! Let us know if you have any more issues :smiley: