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

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

问题描述

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

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

版本:'3'服务:ezmove-2.0:网络模式:主机"建造:语境: .端口:- 5000:5000"

因此,根据上述撰写文件,我正在尝试构建图像,但如何在构建时在 docker-compose 中指定 --network="host" 模式

解决方案

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

版本:'3.4'服务:我的图像:建造:语境: .网络:主机

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

解决方案

@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天全站免登陆