Postgres and Docker compose - unexpected drop database

82 Views Asked by At

I am facing an issue that my Postgres databased has been randomly deleted. On my Mac works fine, but on Ubuntu (arm) server occurs this issue. Any idea why is it happening?

Logs from Postgres

2023-12-20 22:34:28.002 UTC [82] STATEMENT:  SELECT COUNT(*) FROM factory LIMIT 50 
2023-12-20 22:34:30.832 UTC [420] FATAL:  database "template0" is not currently accepting connections
2023-12-20 22:34:31.007 UTC [82] FATAL:  terminating connection due to administrator command
2023-12-20 22:34:31.011 UTC [419] FATAL:  terminating connection due to administrator command
2023-12-20 22:34:31.011 UTC [106] FATAL:  terminating connection due to administrator command
2023-12-20 22:34:31.011 UTC [84] FATAL:  terminating connection due to administrator command
2023-12-20 22:34:31.012 UTC [421] FATAL:  terminating connection due to administrator command
2023-12-20 22:34:31.018 UTC [423] FATAL:  terminating connection due to administrator command
2023-12-20 22:34:31.341 UTC [428] ERROR:  cannot drop the currently open database
2023-12-20 22:34:31.341 UTC [428] STATEMENT:  DROP DATABASE postgres;
2023-12-20 22:34:32.312 UTC [426] ERROR:  duplicate key value violates unique constraint "pg_type_typname_nsp_index"
2023-12-20 22:34:32.312 UTC [426] DETAIL:  Key (typname, typnamespace)=(token_day_data, 2200) already exists.
.
.
.
.
2023-12-20 22:34:33.014 UTC [433] FATAL:  database "squid" does not exist
2023-12-20 22:34:33.047 UTC [435] FATAL:  database "squid" does not exist
2023-12-20 22:34:33.050 UTC [436] FATAL:  database "squid" does not exist
2023-12-20 22:34:33.053 UTC [434] FATAL:  database "squid" does not exist
2023-12-20 22:34:33.061 UTC [437] FATAL:  database "squid" does not exist
2023-12-20 22:34:34.728 UTC [439] FATAL:  database "squid" does not exist
2023-12-20 22:34:34.750 UTC [440] FATAL:  database "squid" does not exist

Docker compose of postgres

db_squid:
    container_name: db_squid
    image: postgres:15
    environment:
      POSTGRES_DB: squid
      POSTGRES_PASSWORD: xxxxxx
    restart: unless-stopped
    volumes:
      - db_squid:/var/lib/postgresql/data
    ports:
      - "5432:5432"
0

There are 0 best solutions below