34

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
  • I think, I have to keep docker container build process seperate from docker-compose, if --network="host" option is not present in docker-compose!
    – Dhairya
    Nov 9, 2017 at 9:12

2 Answers 2

51

@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
  • @I0b0 thanks for answer, but 'network: host' will works only in version '3.4'
    – Dhairya
    Nov 30, 2017 at 7:30
  • 7
    @Dhairya That's why I said "the version number is important"…
    – l0b0
    Nov 30, 2017 at 7:41
6

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

1
  • You can find it here
    – 733amir
    Oct 6, 2021 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.