No DB connection from app to db server after podman deployment

Good afternoon all,

I’m new to both Mattermost and Podman (though I’ve dabbled in Docker before) and I’m having issues deploying a self-hosted Mattermost instance for my small team. Due to the nature of our team, I am restricted to utilizing Podman on a RHEL distribution. I have gone over my podman-compose.yml multiple times and it all appears to be correct, but when I run the podman-compose up -d command the app container always exits in an unhealthy state. The logs suggest that it failed to ping / connect to the db container. I’m honestly at a loss of where to begin.

My server is RHEL 8 and is being hosted on an AWS EC2 instance.

podman-compose.yml

version: '3'

services:
  db:
    container_name: mattermost-db
    image: postgres:latest
    environment:
      POSTGRES_DB: mattermost
      POSTGRES_USER: mattermost
      POSTGRES_PASSWORD: <password>  # Change this to a secure password
    volumes:
      - db-data:/var/lib/postgresql/data
    networks:
      - mattermost-net

  mattermost:
    container_name: mattermost
    image: mattermost/mattermost-team-edition
    depends_on:
      - db
    environment:
      MM_DB_DRIVER: postgres
      MM_DB_HOST: mattermost-db
      MM_DB_NAME: mattermost
      MM_DB_USER: mattermost
      MM_DB_PASSWORD: <password>  # Must match the above
      MM_DB_PORT: '5432'
    ports:
      - "8065:8065"
      - "8067:8067"
    volumes:
      - mattermost-data:/mattermost/data
    networks:
      - mattermost-net

volumes:
  db-data:
  mattermost-data:

networks:
  mattermost-net:
    driver: bridge

Mattermost App Errors:

{"timestamp":"2024-10-22 21:08:22.423 Z","level":"info","msg":"Pinging SQL","caller":"sql/sql_utils.go:67","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@localhost/mattermost_test?binary_parameters=yes&connect_timeout=10&sslmode=disable"}
{"timestamp":"2024-10-22 21:08:22.423 Z","level":"error","msg":"failed to initialize platform: cannot create store: error setting up connections: dial tcp [::1]:5432: connect: connection refused","caller":"commands/server.go:76"}
Error: failed to initialize platform: cannot create store: error setting up connections: dial tcp [::1]:5432: connect: connection refused

As a side note, I’m aware that it appears to be attempting to connect to the db via localhost, but I’m not sure why. I was under the impression that explicitly setting up the environment in the compose file would take care of that, but obviously that isn’t the case…

Any tips or thoughts are appreciated.

I got Mattermost running under podman by spelling out all env variables in podman run. It doesn’t seem to read them from the compose file correctly.

1 Like