3

I want to run my dokcer image in docker-compose with --net = "host" as my docker run with --net = "host" works fine.

But I wanna do it with docker-compose. I also added network_mode: "host" to my docker-compose.yml file. But no chance. Here is my docker-compose.yml file:

version: '2'

services:
  campaign-app-avano-mci:
    image: imagename
    ports:
      - "4558:4558"
    network_mode: "host"
    volumes:
      - /apps/dockers/campaign-app-avano-mci/:/logs
    environment:
      - SDP_MONGO_DATABASE="campaign-app-avano-mci"
      - SDP_SDK_PORT="4558"
      - SDP_PLATFORM_URL="host-platform:9600/aban-platform"

any suggestion?

5
  • What is the issue you face? Because you have used it correctly Commented Aug 28, 2017 at 13:21
  • Tried without the "ports" parameters ? In host mode it is useless Commented Aug 28, 2017 at 14:07
  • I want my container get an IP from docker network and expose mentioned port to main machine. but out hosted application in docker container get time out and make it exit after 1 minutes! Commented Aug 28, 2017 at 14:15
  • To publish a port from a container to the host machine, you don't need network_mode: "host". I'm wondering what host-platform is and how you want to access it. Probably there are some dns resolution problems. Can you find anything in the logs (docker-compose logs campaign-app-avano-mci)? Commented Aug 28, 2017 at 21:38
  • problem resolved! Commented Aug 29, 2017 at 13:36

1 Answer 1

3

problem resolved with following docker-compose.yml file:

services:
  campaign-app-avano-mci:
    image: imagefile
    network_mode: "host"
    ports:
    - 4558:4558
    volumes:
      - /apps/dockers/campaign-app-avano-mci/:/logs
    environment:
      - SDP_MONGO_DATABASE=campaign-app-avano-mci
      - SDP_SDK_PORT=4558
      - SDP_PLATFORM_URL=host-platform:9600/aban-platform
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.