A
A
Andrey2016-12-01 22:51:03
Network administration
Andrey, 2016-12-01 22:51:03

How to bind ports with docker compose?

docker-compose.yml

version: "2"
services:
  rabbitMq:
    container_name: rabbit
    image: rabbitmq:3-management
    environment:
      RABBITMQ_DEFAULT_PASS: pass
      RABBITMQ_DEFAULT_USER: user
      RABBITMQ_DEFAULT_VHOST: vhost
    networks:
      mynet:
        ipv4_address: 172.20.0.4
    ports:
      - "15672:80"
networks:
  mynet:
    driver: bridge
    ipam:
      config:
        - subnet: 172.20.0.0/24
          gateway: 172.20.0.254

I want it to be elementary when a request for 172.20.0.4:80 opens rabbitmq-managment, that is, in the docker, the request gets to 0.0.0.0:15762

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2016-12-02
@goodwin332

From the host system, you should get on 127.0.0.1:15672 to your "rabbitmq-managment"
ip 172.20.0.4 - this is the address inside the docker network.
as for ports:, there are [HOST:CONTAINER] ports.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question