Gitea with Docker and Postgres - Cannot connect using internal network - Synology NAS


#1

I am trying to install Gitea with Postgres on a Synology NAS and I am using the exact docker-compose file as described on Gitea install page.

version: "2"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:latest
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=postgres
      - DB_HOST=db:5432
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
    ports:
      - "3000:3000"
      - "222:22"
    depends_on:
      - db

  db:
    image: postgres:9.6
    restart: always
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=gitea
      - POSTGRES_DB=gitea
    networks:
      - gitea
    volumes:
      - ./postgres:/var/lib/postgresql/data
    ports:
     - "5433:5432"

The only thing I have added to the compose file is a port in the db container to enable access from a external pgadmin.
The docker containers run but then after connecting the gitea webserver and pressing install the gitea container cannot access the db and timeouts. I then changed the db host parameter on gitea install web page to <synology_ip>.5433, connecting from outside the gitea network created by the docker compose file. It then works.
I replicated the setup on docker on windows and it works fine without any change in the compose file suggested in the install section of gitea.
As anyone an idea of why the gitea_server container cannot acess the gitea_db container usign the network gitea_gitea created with the docker-compose file.
Thank you.


#2

Not completely sure what you’re trying to accomplish but here’s another Compose file for reference. Like the one above it uses Posgre and Compose 2.x. Maybe it will help you debug.

https://git.habd.as/comfusion/high-tea/src/branch/master/docker-compose.yml

Also try bumping gitea to 1.6 and back to see if that has any effect on your own setup. For more info on how to do that see Upgrade Gitea Docker Compose.


#3

I reinstalled docker and tried the compose file @balibebas have provided removing the labels and networks. Maybe it was a problem with the latest version of gitea on docker. I tried with gitea version 1.5 and 1.6 on the docker compose file and it fixed the problem. Thanks.