0

Let's assume that I have docker compose as bellow

version: '2.1'

services:

    example-first:
      image: example-first:latest
      container_name: example-first
      ports:
        - "6161:6161"   
      restart: always
      networks:
      - default


        
    example-second:
      image: example-second:latest
      container_name: example-second
      ports:
        - "6767:6767"  
      restart: always
      network_mode: host


networks:
  default:
      driver: bridge

How the second container can receive (send request) the first container? Is it possible?

Thanks in advance!

kamil wilk
  • 117
  • 7
  • 1
    Host networking generally disables Docker's networking, and it should be rarely necessary in practice. If you do use it, the container on the host network behaves exactly the same way as a non-container process would (`ports:` are completely ignored for example) and you have to connect to `localhost` and a published `ports:` of the other container. – David Maze Nov 25 '20 at 19:55
  • I need a host network because I am listening on one microservice for the messages. Thanks for your answer. Please correct me if I am wrong - but it is possible to receive messages from the external device? – kamil wilk Nov 25 '20 at 22:26
  • @DavidMaze (post for marked You, sorry) – kamil wilk Nov 25 '20 at 23:29
  • 1
    Yes, that's exactly what `ports:` is for. – David Maze Nov 25 '20 at 23:33

0 Answers0