sipcapture / homer

HOMER - 100% Open-Source SIP, VoIP, RTC Packet Capture & Monitoring
https://sipcapture.org
GNU Affero General Public License v3.0
1.61k stars 240 forks source link

PostgreSQL fails to start using docker-compose #546

Closed NormB closed 2 months ago

NormB commented 2 years ago

I'm running on Apple silicon (M1) with colima (not docker desktop)

"docker-compose up" failed to complete successfully as shown below

~/homer7-docker/heplify-server/hom7-prom-all   master  docker-compose up Creating network "hom7-prom-all_default" with the default driver Creating loki ... done Creating prometheus ... done Creating grafana ... done Creating nodeexporter ... done Creating db ... done Creating alertmanager ... done Creating heplify-server ... done

ERROR: for homer-webapp Container "779c5720227c" is unhealthy. ERROR: Encountered errors while bringing up the project.

"docker ps" shows that PostgreSQL is failing to start properly.

~/homer7-docker/heplify-server/hom7-prom-all   master  docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f291c7c3998a sipcapture/heplify-server "./heplify-server" 26 seconds ago Up 25 seconds 9090/tcp, 0.0.0.0:9060-9061->9060-9061/tcp, 0.0.0.0:9060->9060/udp, :::9060-9061->9060-9061/tcp, :::9060->9060/udp, 9096/tcp heplify-server 779c5720227c postgres:11-alpine "docker-entrypoint.s…" 27 seconds ago Restarting (1) 10 seconds ago db c7bed9bc99c2 prom/alertmanager:latest "/bin/alertmanager -…" 27 seconds ago Up 25 seconds 9093/tcp alertmanager 2b6115b2b266 prom/node-exporter:latest "/bin/node_exporter …" 27 seconds ago Up 25 seconds 9100/tcp nodeexporter ba9c0e575673 grafana/loki "/usr/bin/loki -conf…" 28 seconds ago Up 26 seconds 0.0.0.0:3100->3100/tcp, :::3100->3100/tcp loki e2938eedf468 grafana/grafana:master "/run.sh" 28 seconds ago Up 26 seconds (healthy) 0.0.0.0:9030->3000/tcp, :::9030->3000/tcp grafana d04ca7363cc6 prom/prometheus:latest "/bin/prometheus --c…" 28 seconds ago Up 26 seconds 9090/tcp prometheus

github-actions[bot] commented 2 years ago

Please star this repository to motivate the developers and to get higher priority! :star:

lmangani commented 2 years ago

Hi @NormB!

Not familiar with collima but the default example containers are x86 based and most likely won't run on AARM64 or M1 docker without custom builds. Is any of them actually starting up?

NormB commented 2 years ago

Hi,

Due to recent licensing changes around docker desktop, it's been removed from all systems (corporate and personal) that I use. Have found that colima works well for my purposes.

It look like all of the containers except PostgreSQL are starting up. Haven't spent much time digging into the PostgreSQL problem. My guess is that it's not too hard to get to the bottom of.

In the past I've had some problems with docker/postgres and (as I recall) something like the following is needed:

-v /root/docker/volumes/postgres:/var/lib/postgresql/data postgres

In addition, I've had some docker/postgres container permissions issues. Successfully fought through these problems in the past. Looks like I might have to do that again unless someone else gets to the bottom of the problem first.

NormB commented 2 years ago

Sigh:

"docker logs db"

... chown: /var/lib/postgresql/data: Permission denied ...

I've seen this in the past as mentioned previously.

lmangani commented 2 years ago

This is easy, just make sure you have the permissions set on the local postgres-data folder it uses to store data

      - ./postgres-data:/var/lib/postgresql/data
NormB commented 2 years ago

In docker-compose.yml, added postgres_data to volumes

volumes:
    prometheus_data: {}
    grafana_data: {}
    postgres_data: {}

Then in the db section, changed the volumes to

volumes:
    - postgres_data:/var/lib/postgresql/data

The startup of the PostgreSQL container now completes.

Do you have any comments or opinions regarding the definition of /var/lib/postgresql/data this way?

NormB commented 2 years ago
diff --git a/heplify-server/hom7-prom-all/docker-compose.yml b/heplify-server/hom7-prom-all/docker-compose.yml
index c801989..d33c8d0 100644
--- a/heplify-server/hom7-prom-all/docker-compose.yml
+++ b/heplify-server/hom7-prom-all/docker-compose.yml
@@ -3,6 +3,7 @@ version: '2.1'
 volumes:
     prometheus_data: {}
     grafana_data: {}
+    postgres_data: {}

 services:
   prometheus:
@@ -190,7 +191,7 @@ services:
     restart: unless-stopped
     volumes:
       - ./init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh
-      - ./postgres-data:/var/lib/postgresql/data
+      - postgres_data:/var/lib/postgresql/data
     healthcheck:
       test: ["CMD-SHELL", "psql -h 'localhost' -U 'root' -c '\\l'"]
       interval: 1s
(END)
NormB commented 2 years ago

The following updates to docker-compose.yml were needed to be able to get PostgreSQL to start and access the web interfaces of the various packages

diff --git a/heplify-server/hom7-prom-all/docker-compose.yml b/heplify-server/hom7-prom-all/docker-compose.yml
index c801989..854a1f3 100644
--- a/heplify-server/hom7-prom-all/docker-compose.yml
+++ b/heplify-server/hom7-prom-all/docker-compose.yml
@@ -3,6 +3,7 @@ version: '2.1'
 volumes:
     prometheus_data: {}
     grafana_data: {}
+    postgres_data: {}

 services:
   prometheus:
@@ -21,6 +22,8 @@ services:
     restart: unless-stopped
     expose:
       - 9090
+    ports:
+      - "9090:9090"
     labels:
       org.label-schema.group: "monitoring"
     logging:
@@ -38,6 +41,8 @@ services:
     restart: unless-stopped
     expose:
       - 9093
+    ports:
+      - "9093:9093"
     labels:
       org.label-schema.group: "monitoring"
     logging:
@@ -62,6 +67,8 @@ services:
     restart: unless-stopped
     expose:
       - 9100
+    ports:
+      - "9100:9100"
     labels:
       org.label-schema.group: "monitoring"
     logging:
@@ -190,7 +197,7 @@ services:
     restart: unless-stopped
     volumes:
       - ./init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh
-      - ./postgres-data:/var/lib/postgresql/data
+      - postgres_data:/var/lib/postgresql/data
     healthcheck:
       test: ["CMD-SHELL", "psql -h 'localhost' -U 'root' -c '\\l'"]
       interval: 1s
kYroL01 commented 1 year ago

Hello @NormB sorry for late answer. In this case, as you did a great job, feel free to send a PR, so we can merge and your contributions will be there :) Thanks !

naqashsaeed commented 2 months ago

Please use this latest Docker compose to install Homer 7 using docker. The above issue is not occurring in this docker-compose.

# docker-compose up -d
WARN[0000] /home/naqash/homer7-docker/heplify-server/hom7-prom-all/docker-compose.yml: `version` is obsolete
[+] Running 8/8
 ✔ Container loki            Running                                                                                                                                                    
 ✔ Container prometheus      Running                                                                                                                                                    
 ✔ Container nodeexporter    Running                                                                                                                                                    
 ✔ Container grafana         Healthy                                                                                                                                                    
 ✔ Container alertmanager    Running                                                                                                                                                    
 ✔ Container db              Healthy                                                                                                                                                    
 ✔ Container heplify-server  Running                                                                                                                                                    
 ✔ Container homer-webapp    Running