How to Specify $docker build --network="host" mode in docker-compose at the time of build

Dhairya picture Dhairya · Nov 2, 2017 · Viewed 13k times · Source

While building docker image like docker build -t name:tag --network="host" so it will Set the networking mode for the RUN instructions during build (default "default")

So I am trying to build Docker image with DOKCER-COMPOSE:

version: '3'
services:
  ezmove-2.0:       
    network_mode: "host"
    build:
      context: .
    ports:
     - "5000:5000" 

So as per above compose file I am trying to build image but how to Specify --network="host" mode in docker-compose at the time of build

Answer

l0b0 picture l0b0 · Nov 29, 2017

@dkanejs is right, and here is how you use it (the version number is important):

version: '3.4'
services:
  my_image:
    build:
      context: .
      network: host