0

I'm using this docker image https://github.com/moodlehq/moodle-docker and it works as advertised. Among other things it exposes web server on localhost:8000 address. What I would like is to bind it to the host's ip instead.

Using raw docker something like that is accomplished with

docker run --network=host [container]

What should be placed in the yml file for docker-compose as documentation is a bit confusing for me.

1
  • Standard practice is to have the server inside the container bind to 0.0.0.0, and use the docker run -p option to publish a port on the host. Commented Aug 15, 2018 at 13:57

1 Answer 1

2

You can use network_mode in compose files -

network_mode: "host"

Sample compose -

version: '3'
services:
  api:
    image: 'node:6-alpine'
    network_mode: host
    environment:
     - NODE_ENV=production
    command: "tail -f /dev/null"

Ref - https://docs.docker.com/compose/compose-file/#network_mode

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.