Docker Community Forums

Share and learn in the Docker community.

Docker network connect and port mapping


(zepouet) #1

Hello Dockers,

I run the following sequence:

docker network create application1
docker run -d -P --name felix1 tomcat

I can access to tomcat mapping exposed port. It is nice :slight_smile:
Now I do :

docker network connect application1 felix1

If I inspect the container via docker cli

“Networks”: {
“application1”: {
“IPAMConfig”: {},
“Links”: null,
“Aliases”: null,
“NetworkID”: “bb1d678041d586bd4b876556b14637cf00e33785e79bbeacddae0598bfc3735a”,
“EndpointID”: “3903a9ef899e93ce10b8b49a68ff746603bdeba8e837125916b295641d62283a”,
“Gateway”: “”,
“IPAddress”: “”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”,
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“MacAddress”: “02:42:ac:12:00:03”
“bridge”: {
“IPAMConfig”: null,
“Links”: null,
“Aliases”: null,
“NetworkID”: “c949dacc1e89524d9c40729ea2dd79a9a48d851becdee007a43a2b8b8150b7ab”,
“EndpointID”: “54f5d1b3a63cb6a849230ff9e82a491cb79e696dfd05e42f3fbb48ff5c0d46c8”,
“Gateway”: “”,
“IPAddress”: “”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”,
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“MacAddress”: “02:42:ac:11:00:01”

But :frowning: I don’t have access to the mapping port. There are always exposed but no way to access to the console without using disconnect.

Therefore if i run this sequence, everything is ok !

docker network create application1
docker run -d -P --name felix1 --net application1 tomcat

So it seems the usecase of connect is different from running a container with –net

I am wrong ? Thanks a lot.
Best regards

My env is this one but i have the same behaviour with 1.9.x

Server Version: 1.10.3
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 56
Dirperm1 Supported: false
Execution Driver: native-0.2
Logging Driver: json-file
Volume: local
Network: bridge null host
Kernel Version: 3.13.0-79-generic
Operating System: Ubuntu 14.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 7.701 GiB