致命:数据库“database_name”不存在 docker postgres

问题描述 投票:0回答:1

我正在使用 VPS 来托管我的 docker 容器。一天一切正常,然后数据库崩溃并显示以下日志。一切似乎都工作正常,直到数据库崩溃。如果您发现任何异常情况,请帮忙并指出。谢谢。我对所有这些东西都很陌生。我只想为我的移动应用程序运行一个小型后端应用程序。难道是我的名为

postgres_data
的 postgres ie 目录的绑定挂载已损坏,因为它仅在我删除
postgres_data
docker compose up
时运行?当我
ssh
进入我的VPS时,有13个僵尸进程。

ps -e

PID TTY          TIME CMD
      1 ?        00:16:23 systemd
      2 ?        00:00:00 kthreadd
      3 ?        00:00:00 rcu_gp
      4 ?        00:00:00 rcu_par_gp
      5 ?        00:00:00 slub_flushwq
      6 ?        00:00:00 netns
      8 ?        00:00:00 kworker/0:0H-events_highpri
     10 ?        00:00:00 mm_percpu_wq
     11 ?        00:00:00 rcu_tasks_rude_
     12 ?        00:00:00 rcu_tasks_trace
     13 ?        00:00:40 ksoftirqd/0
     14 ?        00:13:23 rcu_sched
     15 ?        00:00:10 migration/0
     16 ?        00:00:00 idle_inject/0
     18 ?        00:00:00 cpuhp/0
     19 ?        00:00:00 cpuhp/1
     20 ?        00:00:00 idle_inject/1
     21 ?        00:00:09 migration/1
     22 ?        00:00:47 ksoftirqd/1
     24 ?        00:00:00 kworker/1:0H-events_highpri
     25 ?        00:00:00 kdevtmpfs
     26 ?        00:00:00 inet_frag_wq
     27 ?        00:00:00 kauditd
     28 ?        00:00:05 khungtaskd
     29 ?        00:00:00 oom_reaper
     30 ?        00:00:00 writeback
     31 ?        00:04:16 kcompactd0
     32 ?        00:00:00 ksmd
     33 ?        00:00:25 khugepaged
     80 ?        00:00:00 kintegrityd
     81 ?        00:00:00 kblockd
     82 ?        00:00:00 blkcg_punt_bio
     83 ?        00:00:00 tpm_dev_wq
     84 ?        00:00:00 ata_sff
     85 ?        00:00:00 md
     86 ?        00:00:00 edac-poller
     87 ?        00:00:00 devfreq_wq
     88 ?        00:00:00 watchdogd
     90 ?        00:02:40 kworker/0:1H-kblockd
     92 ?        00:11:41 kswapd0
     93 ?        00:00:00 ecryptfs-kthrea
     95 ?        00:00:00 kthrotld
     96 ?        00:00:00 acpi_thermal_pm
     98 ?        00:00:00 scsi_eh_0
     99 ?        00:00:00 scsi_tmf_0
    100 ?        00:00:00 scsi_eh_1
    101 ?        00:00:00 scsi_tmf_1
    103 ?        00:00:00 vfio-irqfd-clea
    104 ?        00:00:00 mld
    105 ?        00:02:41 kworker/1:1H-kblockd
    106 ?        00:00:00 ipv6_addrconf
    115 ?        00:00:00 kstrp
    118 ?        00:00:00 zswap-shrink
    119 ?        00:00:00 kworker/u5:0
    124 ?        00:00:00 charger_manager
    176 ?        00:00:00 scsi_eh_2
    178 ?        00:00:00 cryptd
    181 ?        00:00:00 scsi_tmf_2
    250 ?        00:00:00 raid5wq
    296 ?        00:02:07 jbd2/sda1-8
    297 ?        00:00:00 ext4-rsv-conver
    394 ?        00:00:00 kaluad
    396 ?        00:00:00 kmpath_rdacd
    401 ?        00:00:00 kmpathd
    403 ?        00:00:00 kmpath_handlerd
    672 ?        00:02:01 dbus-daemon
    681 ?        00:00:12 networkd-dispat
    687 ?        00:00:08 cron
    693 ?        00:00:36 systemd-logind
    700 ?        00:00:00 atd
    723 ttyS0    00:00:00 agetty
    730 tty1     00:00:00 agetty
    731 ?        00:00:00 unattended-upgr
   2807 ?        01:08:58 containerd
   2970 ?        01:04:13 dockerd
 951764 ?        00:09:54 systemd
 951765 ?        00:00:00 (sd-pam)
 994922 ?        00:00:00 sudo
 994923 ?        00:00:00 sudo
 994924 ?        00:00:13 du
1410180 ?        00:00:11 sshd
1414685 ?        00:00:01 docker-proxy
1414693 ?        00:00:01 docker-proxy
1414707 ?        00:05:57 containerd-shim
1414730 ?        00:14:34 java
1415115 ?        00:00:00 curl <defunct>
1415155 ?        00:00:00 curl <defunct>
1415216 ?        00:00:00 curl <defunct>
1415272 ?        00:00:00 curl <defunct>
1415313 ?        00:00:00 curl <defunct>
1415370 ?        00:00:00 curl <defunct>
1415421 ?        00:00:00 curl <defunct>
1415472 ?        00:00:00 curl <defunct>
1415506 ?        00:00:00 curl <defunct>
1415564 ?        00:00:00 curl <defunct>
1415620 ?        00:00:00 curl <defunct>
1415659 ?        00:00:00 curl <defunct>
1415718 ?        00:00:00 curl <defunct>
2270866 ?        00:00:05 irqbalance
2270869 ?        00:00:03 rsyslogd
2270872 ?        00:00:18 systemd-journal
2270873 ?        00:00:00 polkitd
2270880 ?        00:00:00 packagekitd
2270882 ?        00:00:00 systemd-udevd
2270889 ?        00:00:00 systemd-timesyn
2270892 ?        00:00:07 multipathd
2270895 ?        00:03:11 udisksd
2270925 ?        00:00:01 systemd-network
2270934 ?        00:00:00 systemd-resolve
2324197 ?        00:00:02 kworker/0:0-events
2343767 ?        00:00:00 docker-proxy
2343772 ?        00:00:00 docker-proxy
2343786 ?        00:00:59 containerd-shim
2343807 ?        01:59:04 postgres
2343857 ?        00:00:00 docker-proxy
2343863 ?        00:00:00 docker-proxy
2343884 ?        00:00:14 containerd-shim
2343909 ?        00:00:00 sh
2343966 ?        00:00:00 docker-proxy
2343972 ?        00:00:00 docker-proxy
2343987 ?        00:00:00 docker-proxy
2343994 ?        00:00:00 docker-proxy
2344008 ?        00:00:11 containerd-shim
2344030 ?        00:00:00 nginx
2344083 ?        00:00:00 nginx
2344084 ?        00:00:00 nginx
2344260 ?        00:00:06 uwsgi
2344321 ?        00:00:01 uwsgi
2344322 ?        00:00:02 uwsgi
2344323 ?        00:00:05 uwsgi
2344324 ?        00:00:07 uwsgi
2344326 ?        00:00:00 uwsgi
2405838 ?        00:00:05 kworker/u4:5-events_unbound
2416952 ?        00:00:00 postgres
2416953 ?        00:00:01 postgres
2416954 ?        00:00:01 postgres
2416955 ?        00:00:01 postgres
2416956 ?        00:00:03 postgres
2416957 ?        00:00:00 postgres
2476560 ?        00:00:02 kworker/0:1-events
2558957 ?        00:00:00 kworker/1:3-cgroup_destroy
2570873 ?        00:00:00 kworker/u4:1-flush-8:0
2574617 ?        00:00:00 kworker/1:0-ata_sff
2583121 ?        00:00:00 kworker/u4:0-events_unbound
2587679 ?        00:00:00 sshd
2587777 pts/1    00:00:00 bash
2588362 pts/1    00:00:00 docker
2592467 pts/1    00:00:00 docker
2592604 pts/1    00:00:00 docker
2594423 pts/1    00:00:00 docker
2597208 ?        00:00:00 sshd
2597299 pts/2    00:00:00 bash
2599245 ?        00:00:00 sshd
2599914 ?        00:00:00 sshd
2600028 ?        00:00:00 runc
2600038 ?        00:00:00 runc:[2:INIT]
2600045 pts/2    00:00:00 ps

问题似乎就在这里,但我似乎无法弄清楚。

数据库容器的日志是:

2023-09-02 16:45:23.180 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-09-02 16:45:23.180 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-09-02 16:45:23.184 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-09-02 16:45:23.283 UTC [19] LOG:  database system was shut down at 2023-09-02 16:45:11 UTC
2023-09-02 16:45:23.289 UTC [1] LOG:  database system is ready to accept connections
2023-09-02 17:24:42.424 UTC [3452] FATAL:  password authentication failed for user "psql"
2023-09-02 17:24:42.424 UTC [3452] DETAIL:  Role "psql" does not exist.
    Connection matched pg_hba.conf line 95: "host all all all md5"
bash: connect: Operation timed out
bash: line 1: /dev/tcp/104.131.82.44/3232: Operation timed out
bash: line 1: 3: Bad file descriptor
bash: line 1: 3: Bad file descriptor
bash: connect: Operation timed out
bash: line 1: /dev/tcp/104.131.82.44/3232: Operation timed out
bash: line 1: 3: Bad file descriptor
bash: line 1: 3: Bad file descriptor
2023-09-02 17:29:36.959 UTC [1] LOG:  received SIGHUP, reloading configuration files
2023-09-02 17:29:51.675 UTC [1] LOG:  server process (PID 3997) exited with exit code 2
2023-09-02 17:29:51.675 UTC [1] LOG:  terminating any other active server processes
2023-09-02 17:29:51.675 UTC [23] WARNING:  terminating connection because of crash of another server process
2023-09-02 17:29:51.675 UTC [23] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.

HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2023-09-02 17:34:36.878 UTC [1] LOG:  all server processes terminated; reinitializing
2023-09-02 17:34:36.991 UTC [4415] LOG:  database system was interrupted; last known up at 2023-09-02 17:29:52 UTC
2023-09-02 17:34:37.176 UTC [4415] LOG:  could not open file "./pg_mem": Text file busy
2023-09-02 17:34:37.437 UTC [4415] LOG:  database system was not properly shut down; automatic recovery in progress
2023-09-02 17:34:37.441 UTC [4415] LOG:  redo starts at 0/318A028
2023-09-02 17:34:37.441 UTC [4415] LOG:  invalid record length at 0/318DD08: wanted 24, got 0
2023-09-02 17:34:37.441 UTC [4415] LOG:  redo done at 0/318DCD0
2023-09-02 17:34:37.479 UTC [1] LOG:  database system is ready to accept connections
2023-09-02 17:38:58.472 UTC [1] LOG:  server process (PID 4439) was terminated by signal 9
2023-09-02 17:38:58.472 UTC [1] LOG:  terminating any other active server processes
2023-09-02 17:38:58.474 UTC [4419] WARNING:  terminating connection because of crash of another server process
2023-09-02 17:38:58.474 UTC [4419] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2023-09-02 17:38:58.474 UTC [4419] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2023-09-02 17:38:58.476 UTC [1] LOG:  all server processes terminated; reinitializing
2023-09-02 17:38:58.590 UTC [4793] LOG:  database system was interrupted; last known up at 2023-09-02 17:34:37 UTC
2023-09-02 17:38:58.779 UTC [4793] LOG:  could not open file "./pg_mem": Text file busy
2023-09-02 17:38:59.042 UTC [4793] LOG:  database system was not properly shut down; automatic recovery in progress
2023-09-02 17:38:59.048 UTC [4793] LOG:  redo starts at 0/318DD78
2023-09-02 17:38:59.063 UTC [4793] LOG:  invalid record length at 0/3191E88: wanted 24, got 0
2023-09-02 17:38:59.063 UTC [4793] LOG:  redo done at 0/3191E50
2023-09-02 17:38:59.063 UTC [4793] LOG:  last completed transaction was at log time 2023-09-02 17:37:02.674763+00
2023-09-02 17:38:59.091 UTC [1] LOG:  database system is ready to accept connections
2023-09-02 17:43:24.965 UTC [1] LOG:  server process (PID 4817) was terminated by signal 9
2023-09-02 17:43:24.965 UTC [1] LOG:  terminating any other active server processes
2023-09-02 17:43:24.966 UTC [4797] WARNING:  terminating connection because of of crash of another server process

2023-09-02 17:52:41.581 UTC [5996] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2023-09-02 17:52:41.581 UTC [5996] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2023-09-02 17:52:41.582 UTC [1] LOG:  all server processes terminated; reinitializing
2023-09-02 17:52:41.680 UTC [6022] LOG:  database system was interrupted; last known up at 2023-09-02 17:52:32 UTC
2023-09-02 17:52:41.869 UTC [6022] LOG:  could not open file "./pg_mem": Text file busy
2023-09-02 17:52:42.076 UTC [6022] LOG:  database system was not properly shut down; automatic recovery in progress
2023-09-02 17:52:42.080 UTC [6022] LOG:  invalid record length at 0/3196708: wanted 24, got 0
2023-09-02 17:52:42.080 UTC [6022] LOG:  redo is not required
2023-09-02 17:52:42.100 UTC [1] LOG:  database system is ready to accept connections
2023-09-02 17:52:51.974 UTC [1] LOG:  server process (PID 6046) exited with exit code 2
2023-09-02 17:52:51.974 UTC [1] LOG:  terminating any other active server processes
2023-09-02 17:52:51.975 UTC [6026] WARNING:  terminating connection because of crash of another server process
2023-09-02 17:52:51.975 UTC [6026] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2023-09-02 17:52:51.975 UTC [6026] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2023-09-02 17:52:51.979 UTC [1] LOG:  all server processes terminated; reinitializing
2023-09-02 17:52:52.168 UTC [6055] LOG:  database system was interrupted; last known up at 2023-09-02 17:52:42 UTC
2023-09-02 17:52:52.279 UTC [6055] LOG:  could not open file "./pg_mem": Text file busy
2023-09-02 17:52:52.496 UTC [6055] LOG:  database system was not properly shut down; automatic recovery in progress
2023-09-02 17:52:52.500 UTC [6055] LOG:  invalid record length at 0/3196778: wanted 24, got 0
2023-09-02 17:52:52.500 UTC [6055] LOG:  redo is not required
2023-09-02 17:52:52.516 UTC [1] LOG:  database system is ready to accept connections

2023-09-02 18:06:58.290 UTC [1] LOG:  all server processes terminated; reinitializing
2023-09-02 18:06:58.375 UTC [7275] LOG:  database system was interrupted; last known up at 2023-09-02 18:02:32 UTC
2023-09-02 18:06:58.479 UTC [7275] LOG:  could not open file "./pg_mem": Text file busy
2023-09-02 18:06:58.697 UTC [7275] LOG:  database system was not properly shut down; automatic recovery in progress
2023-09-02 18:06:58.703 UTC [7275] LOG:  redo starts at 0/31969A8
2023-09-02 18:06:58.703 UTC [7275] LOG:  invalid record length at 0/31969E0: wanted 24, got 0
2023-09-02 18:06:58.703 UTC [7275] LOG:  redo done at 0/31969A8
2023-09-02 18:06:58.719 UTC [1] LOG:  database system is ready to accept connections
2023-09-02 18:11:44.687 UTC [1] LOG:  server process (PID 7300) was terminated by signal 9
2023-09-02 18:11:44.688 UTC [1] LOG:  terminating any other active server processes
2023-09-02 18:11:44.762 UTC [7279] WARNING:  terminating connection because of crash of another server process
2023-09-02 18:11:44.762 UTC [7279] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2023-09-02 18:11:44.762 UTC [7279] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2023-09-02 18:11:44.765 UTC [1] LOG:  all server processes terminated; reinitializing
2023-09-02 18:11:44.865 UTC [7690] LOG:  database system was interrupted; last known up at 2023-09-02 18:06:58 UTC
2023-09-02 18:11:44.974 UTC [7690] LOG:  could not open file "./pg_mem": Text file busy
2023-09-02 18:11:45.231 UTC [7690] LOG:  database system was not properly shut down; automatic recovery in progress
2023-09-02 18:11:45.234 UTC [7690] LOG:  redo starts at 0/3196A50
2023-09-02 18:11:45.234 UTC [7690] LOG:  invalid record length at 0/3196A88: wanted 24, got 0
2023-09-02 18:11:45.234 UTC [7690] LOG:  redo done at 0/3196A50
2023-09-02 18:11:45.246 UTC [1] LOG:  database system is ready to accept connections
2023-09-02 18:11:51.568 UTC [1] LOG:  server process (PID 7713) exited with exit code 2
2023-09-02 18:11:51.568 UTC [1] LOG:  terminating any other active server processes
2023-09-02 18:11:51.568 UTC [7694] WARNING:  terminating connection because of crash of another server process

9 UTC [1] LOG:  all server processes terminated; reinitializing
2023-09-02 19:28:09.564 UTC [14359] FATAL:  the database system is in recovery mode
2023-09-02 19:28:09.564 UTC [14358] LOG:  database system was interrupted; last known up at 2023-09-02 19:23:28 UTC
2023-09-02 19:28:09.871 UTC [14358] LOG:  database system was not properly shut down; automatic recovery in progress
2023-09-02 19:28:09.874 UTC [14358] LOG:  redo starts at 0/31A13E8
2023-09-02 19:28:09.874 UTC [14358] LOG:  invalid record length at 0/31A1420: wanted 24, got 0
2023-09-02 19:28:09.874 UTC [14358] LOG:  redo done at 0/31A13E8
2023-09-02 19:28:09.890 UTC [1] LOG:  database system is ready to accept connections
2023-09-02 20:10:05.562 UTC [17571] LOG:  invalid length of startup packet
2023-09-02 22:46:20.462 UTC [29593] LOG:  invalid length of startup packet
2023-09-02 23:44:41.701 UTC [34103] ERROR:  cannot drop table spatial_ref_sys because extension postgis requires it
2023-09-02 23:44:41.701 UTC [34103] HINT:  You can drop extension postgis instead.
2023-09-02 23:44:41.701 UTC [34103] STATEMENT:  DROP TABLE IF EXISTS spatial_ref_sys CASCADE;
2023-09-02 23:44:42.467 UTC [34105] FATAL:  database "template0" is not currently accepting connections
2023-09-02 23:44:43.201 UTC [34106] ERROR:  cannot drop table spatial_ref_sys because extension postgis requires it
2023-09-02 23:44:43.201 UTC [34106] HINT:  You can drop extension postgis instead.
2023-09-02 23:44:43.201 UTC [34106] STATEMENT:  DROP TABLE IF EXISTS spatial_ref_sys CASCADE;
2023-09-02 23:44:44.262 UTC [34109] ERROR:  cannot drop the currently open database
2023-09-02 23:44:44.262 UTC [34109] STATEMENT:  DROP DATABASE postgres;
2023-09-02 23:44:45.100 UTC [34118] ERROR:  cannot drop a template database
2023-09-02 23:44:45.100 UTC [34118] STATEMENT:  DROP DATABASE template_postgis;
2023-09-03 00:01:48.464 UTC [35490] FATAL:  database "ag_db" does not exist
2023-09-03 00:01:48.564 UTC [35491] FATAL:  database "ag_db" does not exist
2023-09-03 00:01:48.570 UTC [35492] FATAL:  database "ag_db" does not exist
2023-09-03 00:01:48.575 UTC [35493] FATAL:  database "ag_db" does not exist
2023-09-03 00:01:48.580 UTC [35494] FATAL:  database "ag_db" does not exist
2023-09-03 00:01:48.665 UTC [35495] FATAL:  database "ag_db" does not exist

还有

2023-09-04 06:14:09.613 UTC [1209] LOG:  incomplete startup packet
chattr: setting flags on /tmp/: Operation not permitted
chattr: setting flags on /var/tmp/: Operation not permitted
chattr: setting flags on /var/spool/cron: Operation not permitted
chattr: can't open '/var/spool/cron/crontabs': Symbolic link loop
chattr: can't stat '/etc/crontab': No such file or directory
bash: line 8: ufw: command not found
bash: line 9: iptables: command not found
bash: line 11: sudo: command not found
bash: line 12: /proc/sys/kernel/nmi_watchdog: Read-only file system
bash: line 13: /etc/sysctl.conf: Permission denied
bash: line 14: userdel: command not found
bash: line 15: userdel: command not found
chattr: can't stat '/root/.ssh/': Permission denied
chattr: can't stat '/root/.ssh/authorized_keys': Permission denied
crontab: must be suid to work properly
crontab: must be suid to work properly
crontab: must be suid to work properly
crontab: must be suid to work properly
crontab: must be suid to work properly
crontab: must be suid to work properly

docker-compose.prod.yml

version: "3"

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile.prod
    restart: always
    ports:
      - 8000:8000
    volumes:
      - ./sock/:/sock/
      - ./:/code
      - ./logs/:/logs/
    entrypoint: sh /code/docker-entrypoint.prod.sh
    env_file:
      - .env
    depends_on:
      - db
    networks:
      - test_nw
    
    deploy:
      resources:
        limits:
          cpus: "0.3"
          memory: "300M"

  db:
    image: mdillon/postgis:11-alpine
    restart: always
    volumes:
      - ./postgres_data:/var/lib/postgresql/data/
    ports:
      - 5432:5432
    
    env_file:
      - .db_env
    networks:
      - test_nw
    deploy:
      resources:
        limits:
          cpus: "0.3"
          memory: "300M"

    healthcheck:
       test: ["CMD-SHELL", "pg_isready -U postgres"]
       interval: 5s
       timeout: 5s
       retries: 5

  nginx:
    image: nginx:latest
    restart: always
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./nginx/nginx-proxy.conf:/etc/nginx/conf.d/default.conf   
      - ./frontend_app/dist:/var/www/frontend
      - ./sock/:/sock/
      - ./logs/nginx:/var/log/nginx
      - ./static:/static
      - ./media:/media
    depends_on:
      - web

    networks:
      - test_nw
    deploy:
      resources:
        limits:
          cpus: "0.2"
          memory: "200M"

networks:
  test_nw:
    driver: bridge

这是我的

.env

POSTGRES_DB=ag_db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=******
POSTGRES_HOST=db
POSTGRES_PORT=5432

.db_env

POSTGRES_USER=postgres
POSTGRES_DB=ag_db
POSTGRES_PASSWORD=postgres

docker-entrypoint.prod.sh

#!/bin/sh
python3 manage.py collectstatic --noinput
#python manage.py makemigrations --merge --noinput
python3 manage.py migrate --noinput
uwsgi --ini uwsgi.ini

Dockerfile.prod

FROM python:3.9-slim

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWEITEBYTECODE 1

RUN mkdir -p /code
RUN mkdir -p /logs
RUN mkdir -p /sock

WORKDIR /code

COPY apt_requirements.txt /code/
RUN apt-get -y update
RUN cat apt_requirements.txt | xargs apt -y --no-install-recommends install \
    && rm -rf /var/lib/apt/lists/* \
    && apt autoremove \
    && apt autoclean

WORKDIR /code

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWEITEBYTECODE 1

COPY apt_requirements.txt /code/
RUN apt-get -y update
RUN cat apt_requirements.txt | xargs apt -y --no-install-recommends install \
    && rm -rf /var/lib/apt/lists/* \
    && apt autoremove \
    && apt autoclean

ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
ENV C_INCLUDE_PATH=/usr/include/gdal

COPY requirements.txt /code/


RUN pip install setuptools==57.5.0
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /code/wheels -r requirements.txt

###FINAL IMAGE
FROM python:3.9-slim

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWEITEBYTECODE 1

RUN mkdir -p /code
RUN mkdir -p /logs
RUN mkdir -p /sock

WORKDIR /code

COPY apt_requirements.txt /code/
RUN apt-get -y update
RUN cat apt_requirements.txt | xargs apt -y --no-install-recommends install \
    && rm -rf /var/lib/apt/lists/* \
    && apt autoremove \
    && apt autoclean

COPY --from=builder /code/wheels /wheels
COPY --from=builder /code/requirements.txt ./
RUN pip install --no-cache /wheels/*
ENTRYPOINT /code/docker/docker-entrypoint.prod.sh
postgresql docker docker-compose dockerfile postgis
1个回答
0
投票

我已经解决了这个问题,在我的 docker-compose 文件中设置这一行:

healthcheck:
  test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
© www.soinside.com 2019 - 2024. All rights reserved.