如何指定 $docker build --network=“host"构建时 docker-compose 中的模式 [英] How to Specify $docker build --network="host" mode in docker-compose at the time of build

查看:81
本文介绍了如何指定 $docker build --network=“host"构建时 docker-compose 中的模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构建像 docker build -t name:tag --network="host" 这样的 docker 映像时,它将在构建期间为 RUN 指令设置网络模式(默认为默认")

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")

所以我正在尝试使用 DOKCER-COMPOSE 构建 Docker 映像:

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" 

所以按照上面的撰写文件,我正在尝试构建映像,但是如何在构建时在 docker-compose 中指定 --network="host" 模式

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

推荐答案

@dkanejs 是对的,方法如下你用它(版本号很重要):

@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

这篇关于如何指定 $docker build --network=“host"构建时 docker-compose 中的模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆