The --network parameter of docker build image actually does not refer to a network, but to the networking mode for the RUN instructions during build.
The Docker semantics is not consistent in this case (and it sucks), since in docker run , the --network connects a container to a network (it should be called --networking-mode in docker build image ).
Related to: Is "docker build --network=host" working as expected? - #3 by nickyayoub