1

I'm trying to use server(host) network setting for docker container also. I'm able to do it using docker run command but not able to do it using docker-compose. I'm trying to achieve same behaviour as the command -

sudo docker run -p 8001:8001 -d --network host --name container_name image_name

using docker-compose. All the solution I found in internet are not working.

here is my docker-compose.yml

version: '3.4'

services:

    e-si:
        build: ./path/to/project
        networks : host
        ports:
            - 8001:8001
        volumes:
            - /server/location:/container/location

Can anyone tell me what I'm doing wrong?

Thanks in advance.

1 Answer 1

2

Use network_mode:

Network mode. Use the same values as the docker client --network parameter, plus the special form service:[service name].

version: '3.4'
services:
  e-si:
    build: ./path/to/project
    network_mode: "host"
    volumes:
      - /server/location:/container/location
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.