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

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

问题描述

在构建docker映像(如docker build -t name:tag --network="host")时,它将在构建期间为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天全站免登陆