Docker Community Forums

Share and learn in the Docker community.

Network_mode: "host" breaking port mapping


(Ctaormina) #1

Expected behavior

I have the following docker-compose file. I was able to just both the ports option to map the ports to my mac localhost and use the network_mode to reach other services mapped to my local host. However that no longer seems to be the case. Is this broken or am I using this incorrectly? I am starting this with docker-compose run --service-ports --rm app

Actual behavior

With the network_mode : host option I cannot hit this service from localhost:3001. But without it I can, and it cannot hit other services at


version: "2"
image: node
- “”
- ""
- deployment/defaults.env
- deployment/dev.env
- .:/app
- "3001"
- "3001:3001"
network_mode: "host"
command: [sh,]

running docker services:

f0d2588bdb14 devopsdockerlocaldev_dynamodb "/bin/sh -c 'java " 16 minutes ago Up 16 minutes>8000/tcp dynamodb-1
78ab60133522 postgres “/docker-entrypoint.s” 16 minutes ago Up 16 minutes>5432/tcp postgres-1
e653a7b350e0 mongo “/ mongo” 16 minutes ago Up 16 minutes>27017/tcp mongo-1
7d2c5e8a9005 innroad/swagger-ui “/bin/sh -c './node_m” 16 minutes ago Up 16 minutes>8080/tcp swagger-1
0b984abd6b71 rabbitmq:3-management “” 16 minutes ago Up 16 minutes 4369/tcp, 5671/tcp,>5672/tcp, 15671/tcp, 25672/tcp,>15672/tcp rabbit-1

Moby Menu > Diagnose & Feedback on OSX
Docker for Mac: version: mac-v1.12.0-beta20
OS X: version 10.11.3 (build: 15D21)
logs: /tmp/20160725-143932.tar.gz
[OK] docker-cli
[OK] app
[OK] moby-syslog
[OK] virtualization
[OK] menubar
[OK] system
[OK] osxfs
[OK] db
[OK] slirp
[OK] moby-console
[OK] logs
[OK] vmnetd
[OK] env
[OK] moby
[OK] driver.amd64-linux