Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 781
Dhairya Avatar asked Nov 02 '17 11:11

Dhairya


People also ask

What is network mode in Docker compose?

Docker Compose sets up a single network for your application(s) by default, adding each container for a service to the default network. Containers on a single network can reach and discover every other container on the network.

What is Docker default network mode?

Bridge mode (the default Docker networking mode) The Docker deamon creates “docker0” a virtual ethernet bridge that forwards packets between all interfaces attached to it.


2 Answers

@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 
like image 112
l0b0 Avatar answered Oct 06 '22 09:10

l0b0


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

like image 38
syncdk Avatar answered Oct 06 '22 11:10

syncdk