Host networking does not work with version 2 format
$ docker-compose --version
docker-compose version 1.6.0, build unknown
version: "2"
networks:
default:
external:
name: host
services:
huh:
image: alpine:3.3
command: sleep 3600
ERROR: Container cannot be disconnected from host network or connected to host network
I can't find how to make it work with the new version. If there is no way, then there should be one. If there is a way, it should be documented.
https://docs.docker.com/compose/compose-file/#upgrading:91de898b5f5cdb090642a917d3dedf68 (see net -> network_mode)
https://docs.docker.com/compose/compose-file/#network-mode:91de898b5f5cdb090642a917d3dedf68
Thanks!
@dnephin Sorry about commenting on a closed issue - but I'm having exactly the same problem as @bobrik but I can't figure out what your response means. As far as I can tell from the official documentation (https://docs.docker.com/compose/compose-file/#/external), the code shown above should be correct, is it not?
The host network is special. You have to use network_mode: host on the service
Sorry for reopening this, but is there any way to add the host network under the networks tag. I need both a container to be both connected to a bridge network and the host one, so I cannot use the network_mode option.
I have the same question. It would be great to get a response. Or if there is some other configuration that can achieve this goal.
@dnephin according to documentation on docker-compose network-mode is ignored.
This option is ignored when deploying a stack in swarm mode with a (version 3) Compose file.
@bhairav13 , @mangelov95 ,
Did you find answer to your situation. We are having similar problem statement. We need to connect a container to both bridge and host networks.
Thanks
has anyone found a solution to this problem? we are also having issues with it :(