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

淺唱寂寞╮ 提交于 2019-11-29 18:28:21

问题


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


回答1:


@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



回答2:


Looks as though the option was added in the latest version but is nowhere to be found in the docker-compose online documentation.



来源:https://stackoverflow.com/questions/47074457/how-to-specify-docker-build-network-host-mode-in-docker-compose-at-the-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!