Docker: Using the host's network

2 min read | by Jordi Prats

If we use the --net=host option with docker to create a new container, it will share it's network namespace with the host machine. It's main advantage is that it will provide higher performance (it will be close to bare metal speed); however, we might get port conflicts.

If we are not interested on it's higher performance, we might still need it if we are unable to use the docker's network due to some conflict with other networks we have:

$ docker run -it --rm mysql mysql
ERROR 2005 (HY000): Unknown MySQL server host '' (-3)

We can workaround it by skipping the docker network using the mentioned --net=host option:

$ docker run --net=host -it --rm mysql mysql

Since we are just connecting to a remote host we won't face any port conflicts. If we want to permanently fix this issue, we can also change the default bridge IP (bip) and the default-address-pools on the /etc/docker/daemon.json file

  "bip": "",
  "default-address-pools": [

Posted on 24/02/2022