Docker Community Forums

Share and learn in the Docker community.

Network_mode: "host" breaking port mapping

docker

(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 127.0.0.1

Information

-docker-compose
version: "2"
services:
app:
image: node
extra_hosts:
- “dynamo.local.com:127.0.0.1”
- "fluent.logger.com:127.0.0.1"
env_file:
- deployment/defaults.env
- deployment/dev.env
volumes:
- .:/app
expose:
- "3001"
ports:
- "3001:3001"
network_mode: "host"
command: [sh, cmd.sh]

running docker services:

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