Port Not Published for Matrix Chat Server with Docker and Portainer

Hello everyone,

I am completely new to Docker. Ten years ago, I worked with Linux servers and now I want to dive into this magical Docker world. I am currently trying to set up a Matrix chat server and I am using Portainer to manage my containers.

I have written a Docker Compose file that creates the server and the database. Unfortunately, no port is being published through which I can access the server with my reverse proxy (see picture). I am not sure what I am doing wrong and I am really desperate right now.

Here is my Docker Compose file:

version: '3.7'

services:
  db:
    container_name: 'matrix-synapse-db'
    image: postgres:13
    restart: always
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: password
      POSTGRES_DB: synapse
    volumes:
      - synapse_db:/var/lib/postgresql/data

  synapse:
    image: matrixdotorg/synapse:latest
    container_name: 'matrix-synapse-server'
    ports:
      - "8008:8008"
    restart: always
    depends_on:
      - db
    environment:
      - VIRTUAL_HOST=mysubdomain.mydomain.de
      - VIRTUAL_PORT=8008
      - LETSENCRYPT_HOST=mysubdomain.mydomain.de
      - SYNAPSE_SERVER_NAME=mysubdomain.mydomain.de
      - SYNAPSE_REPORT_STATS=yes
    networks:
      - ngx-proxy-dns_default
    volumes:
      - synapse_data:/data
      - "./data:/data"
    command: >
      /start.py
      --config-path=/data/homeserver.yaml

networks:
  ngx-proxy-dns_default:
    external: true

volumes:
  synapse_db:
  synapse_data:

When I run the docker-compose in Portainer, everything seems to start correctly, but I cannot reach the server via port 8008. My reverse proxy shows no connection.

What am I doing wrong? Do I need to make any special settings in Portainer, Docker, or in the Compose file to publish the port correctly?

Thank you in advance for your help!

It is not just tht your container has no port forwarded, but has no IP address so it is probably not running at all.

I can’t make any sense of this sentence. I have never entered an IP in any Compose so far. I only have one physical machine with an IP. I have now entered this once, on the advice of ChatGPT, but it didn’t help at all.

    networks:
      default:
        ipv4_address: 172.20.0.4

networks:
  default:
    driver: bridge
    ipam:
      config:
        - subnet: 172.20.0.0/16

Now the container doesn’t start at all. I already have SearXNG and NGINX running without problems and without entering an IP in the Docker Compose.

It is interesting, when I start the docker-compose, it shows me that the container is starting with an IP and port (see image). However, once the container is up, the port and IP are gone, and the container is not reachable.

I’m about to lose my mind…

And I didn’t suggest it either. I was writing about the screenshot on which I missed the “running” status, but that is just portainer which I don’t use as it works as an additional layer on top of Docker. I can’t talk about how Portainer works. I installed it in a recent tutorial just to show it exists, but when you are trying to debug, Portainer can be good for checking logs, but anything you see on the GUI, can be misleading so you should always work in the terminal as well.

It proves my point. It looks like the container stopes. If the process in the container stops, the container stops. Portainer doesn’t always updates the status on the screen, so if the container is restarting, you could see it is running, even if the IP address is not available since it is actually not running. Why it stops can be found out by checking the logs and it helps if you understand what the command does that you set to run in the container :slight_smile: I have no idea how that image works and how start.py is supposed to work. One general fact is that the process you run must run in the foreground inside the container without failing, so a command that runs a service in the background would not work.

About the container status, I can show what I experienced during my last video tutorial, but it is Hungarian and the English version is not finished yet, so ignore or mute the audio :slight_smile: Just watch how I had to reload the page at 48:48: https://youtu.be/cMEce-MrDtM?t=2928

I could have just cicked on the reload button inside Portainer, I didn’t notice.

1 Like