Search code examples
dockermacosdocker-composepgadmin-4docker-desktop

pgadmin 4 is broken after running docker-compose file


pls help i am stuck I downloaded pgadmin4 to my mac. I was using it smoothly. Then I had to clone a repository. In read me file it wanted me to run a docker file and it is like (xxx is for replaced by me):

version: '1.0'

services:

  postgresql-server:
    hostname: postgresql-server
    container_name: postgresql-server
    build:
      context: .
      dockerfile: postgres.dockerfile
    pull_policy: if_not_present
    networks:
      - xxx-network
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_PASSWORD=xxxx
      - POSTGRES_USER=postgres
      - POSTGRES_DB=xxxxx
      - PG_DATA=/var/lib/postgresql/data
    volumes:
      - xxx_postgresql_data:/var/lib/postgresql/data
    restart: unless-stopped

After running that it gives me an error saying that "Failed to bind tcp 0.0.0.0:5432 address already in use". And then I found the processes with:

sudo lsof -i :5432
sudo kill -9 <pid>

After these commands I run the docker-compose.yml file again and it worked well. Then I stoped container via docker desktop. And then when I tried to open pgadmin4 it gives this error. Here is full error log:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               pgAdmin 4 [686]
Path:                  /Users/USER/pgAdmin 4.app/Contents/MacOS/pgAdmin 4
Identifier:            org.pgadmin.pgadmin4
Version:               7.8 (4280.88)
Code Type:             X86-64 (Translated)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-12-04 21:05:12.4334 +0300
OS Version:            macOS 13.2.1 (22D68)
Report Version:        12
Anonymous UUID:        03E8CE3A-836D-7497-A70C-08F1E755F39E


Time Awake Since Boot: 73 seconds

System Integrity Protection: enabled

Crashed Thread:        0  CrBrowserMain  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000020
Exception Codes:       0x0000000000000001, 0x0000000000000020

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [686]

VM Region Info: 0x20 is not in any region.  Bytes before following region: 140722774196192
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      mapped file              7ffc92f7c000-7ffc9da48000 [170.8M] r-x/r-x SM=COW  ...t_id=42c7dba5

Kernel Triage:
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage


Thread 0 Crashed:: CrBrowserMain Dispatch queue: com.apple.main-thread
0   ???                                    0x100269080 ???
1   nwjs Framework                         0x11e114522 0x114790000 + 160974114
2   libsystem_platform.dylib            0x7ff80849bc33 _sigtramp + 51
3   nwjs Framework                         0x11e114522 0x114790000 + 160974114
4   nwjs Framework                         0x11e3311f0 0x114790000 + 163189232
5   nwjs Framework                         0x11e3a10db 0x114790000 + 163647707
6   nwjs Framework                         0x11ac9051a 0x114790000 + 105907482
7   nwjs Framework                         0x11ac988d9 0x114790000 + 105941209
8   nwjs Framework                         0x11bc274bd 0x114790000 + 122254525
9   nwjs Framework                         0x11bc25c46 0x114790000 + 122248262
10  nwjs Framework                         0x11e332de5 0x114790000 + 163196389
11  nwjs Framework                         0x11e3adc97 0x114790000 + 163699863
12  nwjs Framework                         0x11e0e2cd5 0x114790000 + 160771285
13  nwjs Framework                         0x11e0e1f17 0x114790000 + 160767767
14  nwjs Framework                         0x11b78a259 0x114790000 + 117416537
15  nwjs Framework                         0x117bfccb0 0x114790000 + 54971568
16  nwjs Framework                         0x117bff494 0x114790000 + 54981780
17  nwjs Framework                         0x117bff927 0x114790000 + 54982951
18  nwjs Framework                         0x117bfba63 0x114790000 + 54966883
19  nwjs Framework                         0x11779e179 0x114790000 + 50389369
20  nwjs Framework                         0x117bfc1c6 0x114790000 + 54968774
21  nwjs Framework                         0x119a4ef90 0x114790000 + 86765456
USB Device: USB31Bus
Thunderbolt Bus: MacBook Air, Apple Inc.
Thunderbolt Bus: MacBook Air, Apple Inc.

Then I restared my computer and see that this processes starts automatically:

 sudo lsof -i :5432
Password:
COMMAND  PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
postgres 363 postgres    7u  IPv6 0x1d6be6a57a65ede5      0t0  TCP *:postgresql (LISTEN)
postgres 363 postgres    8u  IPv4 0x1d6be6a0a8cbc5ed      0t0  TCP *:postgresql (LISTEN)

And I cannot start my pgadmin eventhough this processes are running and other containers are stopped. Do you have any idea to solve that?


Solution

  • Unless you have done other things, running the command docker compose -f <path_to_docker_compose_file> down and then restarting your PC should solve your issue.

    Note that restart: unless-stopped is key because it will make your container run even between system restarts unless you manually stop the container (which is exactly what this configuration indicates). You have likely just reversed the issue: initially, you couldn't run the container because the port was already in use, but now it's the container that has the port occupied.

    For future reference, instead of killing processes on your system, you can specify which port of your host the container should use, for example:

    ports:
        - "2345:5432"