docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings

It is like terpz wrote: the validation aims to prevent ambigous miss configuration. It should have existed from day 1. Seems it was missed until recently.

When network_mode: host is used the port mapping is ignored. The container will use the hosts network namespace and act network-wise like any other local process on the machine. There is no portmapping involved, as there is no privat network to map to.

I am puzzled why someone would spend time in fighting a validation warning caused by an incosistent configuration (network_mode: host and port mappings at the same time) instead of just removing the incosistancy (the port mappings) as they are ignored anyway.

1 Like