Score:0

Web interface in Docker container not accessible

ao flag

I am currently setting up a system that is composed of different Docker containers that somehow have to communicate with each other.

One Docker container is dedicated to a XMPP server (prosody). This container is started by following docker-compose.yml:

version: "3.8"

services:

  prosody_server:
    container_name: prosody_server
    build:
      context: ./
      dockerfile: Dockerfile
    ports:
      - "5222:5222"
      - "5269:5269"
      - "5347:5347"

When I run docker ports on that container, I get following output implying that the mapping of the ports works:

5222/tcp -> 0.0.0.0:5222
5269/tcp -> 0.0.0.0:5269
5347/tcp -> 0.0.0.0:5347

The second Docker container runs a Python script that interacts with the XMPP server and further hosts a simple web interface. My problem is that the second Docker container for some reason can only communicate with the XMPP server in the first container, if I set network_mode: "host" in the docker-compose.yml that starts the Python script:

version: '3.8'

services:
  python_script:
    build:
      context: ../
      dockerfile: docker/Dockerfile
    container_name: python_script
    stdin_open: true
    network_mode: 'host'
    working_dir: '/python'
    command: bash -c 'python main.py'

In this case, I can run the Docker container with the Python script successfully and it is able to communicate with the XMPP server.
However, the web interface is not accessible in that case. It is hosted using the library aiohttp and serves 0.0.0.0:8080.
Using the bash of the Docker container serving the Python script, I can successfully request the interface by entering curl localhost:8080, but it is not accessible from outside the container.
As far as I understood, using network_mode: "host" would theoretically enable be to use curl localhost:8080 analogously on my host machine, but is does not work.
Changing the network configuration of either the XMPP server's Docker container or the container of the Python script also did not work, as this interferes with the communication between these containers.
I also added exceptions to my firewall and temporally disabled it completely, but this didn't solve the problem.

jp flag
If these services are in different docker-compose projects then they have separate networks attached. These networks are isolated from each other.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.