docker-library / postgres

Docker Official Image packaging for Postgres
http://www.postgresql.org
MIT License
2.14k stars 1.11k forks source link

sh: locale: not found #337

Closed bkuhl closed 6 years ago

bkuhl commented 6 years ago

I have the 9.6-alpine container running (I've also tried just using 9.6) and am running into a locale issue.

Kubernetes Configuration

      - name: postgres
        image: postgres:9.6-alpine
        imagePullPolicy: IfNotPresent
        env:
          - { name: "POSTGRES_DB", value: "app_db" }
          - { name: "POSTGRES_USER", value: "db_user" }
          - { name: "POSTGRES_PASSWORD", valueFrom: { secretKeyRef: { name: laravel-starter-secrets, key: db.password }} }

Container Output

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
 The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
 Data page checksums are disabled.
 fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... No usable system locales were found.
Use the option "--debug" to see details.
sh: locale: not found
ok
 WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
syncing data to disk ... ok
 Success. You can now start the database server using:
     pg_ctl -D /var/lib/postgresql/data -l logfile start
 waiting for server to start....LOG:  database system was shut down at 2017-09-13 14:17:11 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
 done
server started
CREATE DATABASE
 CREATE ROLE
 /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
 waiting for server to shut down....LOG:  received fast shutdown request
LOG:  aborting any active transactions
LOG:  autovacuum launcher shutting down
LOG:  shutting down

I'm unsure how to pass --debug given the initialization script in this container. How can I debug what's happening here? My assumption is that the locale issue is preventing the container from running since I don't see any other issues in this output.

yosifkit commented 6 years ago

Nothing is wrong, this is the natural startup of the image. The entrypoint starts PostgreSQL server as a background process that only listens on localhost, then after completing the user and database creation (and running any scripts in /docker-entrypoint-initdb.d/) it then shuts down the limited PostgreSQL server. It then replaces the running bash process (via exec) with a new start of PostgreSQL server that listens publicly which should be just a few lines later in your logs after the "PostgreSQL init process complete; ready for start up."

AnurupMondal commented 4 weeks ago

I get what you want to say but when i try to access the database after it says that "ready for startup" it fails Here's the error I am getting:


  The files belonging to this database system will be owned by user "postgres".
  This user must also own the server process.
  The database cluster will be initialized with locale "en_US.utf8".
  The default database encoding has accordingly been set to "UTF8".
  The default text search configuration will be set to "english".
  Data page checksums are disabled.
  fixing permissions on existing directory /var/lib/postgresql/data ... ok
  creating subdirectories ... ok
  selecting dynamic shared memory implementation ... posix
  selecting default max_connections ... 100
  selecting default shared_buffers ... 128MB
  selecting default time zone ... UTC
  creating configuration files ... ok
  running bootstrap script ... ok
  sh: locale: not found
  2024-06-19 03:59:56.827 UTC [31] WARNING:  no usable system locales were found
  performing post-bootstrap initialization ... ok
  syncing data to disk ... ok
  Success. You can now start the database server using:
      pg_ctl -D /var/lib/postgresql/data -l logfile start
  initdb: warning: enabling "trust" authentication for local connections
  initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
  waiting for server to start....2024-06-19 04:00:04.788 UTC [37] LOG:  starting PostgreSQL 16.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309, 64-bit
  2024-06-19 04:00:04.795 UTC [37] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
  2024-06-19 04:00:04.830 UTC [40] LOG:  database system was shut down at 2024-06-19 04:00:01 UTC
  2024-06-19 04:00:04.883 UTC [37] LOG:  database system is ready to accept connections
  2024-06-19 04:00:04.890 UTC [43] LOG:  TimescaleDB background worker launcher connected to shared catalogs
   done
  server started
  CREATE DATABASE
  /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/000_install_timescaledb.sh
  CREATE EXTENSION
  CREATE EXTENSION
  2024-06-19 04:00:08.798 UTC [61] ERROR:  TimescaleDB background worker connected to template database, exiting
  2024-06-19 04:00:08.801 UTC [37] LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 61) exited with exit code 1
  CREATE EXTENSION
  /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/001_timescaledb_tune.sh
  Using postgresql.conf at this path:
  /var/lib/postgresql/data/postgresql.conf
  Writing backup to:
  /tmp/timescaledb_tune.backup202406190400
  Recommendations based on 15.22 GB of available memory and 16 CPUs for PostgreSQL 16
  shared_buffers = 3897MB
  effective_cache_size = 11691MB
  maintenance_work_mem = 1948MB
  work_mem = 2494kB
  timescaledb.max_background_workers = 16
  max_worker_processes = 35
  max_parallel_workers_per_gather = 8
  max_parallel_workers = 16
  wal_buffers = 16MB
  min_wal_size = 512MB
  default_statistics_target = 100
  random_page_cost = 1.1
  checkpoint_completion_target = 0.9
  max_locks_per_transaction = 256
  autovacuum_max_workers = 10
  autovacuum_naptime = 10
  effective_io_concurrency = 256
  timescaledb.last_tuned = '2024-06-19T04:00:09Z'
  timescaledb.last_tuned_version = '0.15.0'
  Saving changes to: /var/lib/postgresql/data/postgresql.conf
  /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
  CREATE SCHEMA
  CREATE TABLE
  CREATE TABLE
  CREATE TABLE
  DO
  CREATE TABLE
  waiting for server to shut down...2024-06-19 04:00:09.930 UTC [37] LOG:  received fast shutdown request
  .2024-06-19 04:00:09.934 UTC [37] LOG:  aborting any active transactions
  2024-06-19 04:00:09.934 GMT [64] FATAL:  terminating background worker "TimescaleDB Background Worker Scheduler" due to administrator command
  2024-06-19 04:00:09.934 UTC [55] FATAL:  terminating background worker "TimescaleDB Background Worker Scheduler" due to administrator command
  2024-06-19 04:00:09.934 UTC [43] FATAL:  terminating background worker "TimescaleDB Background Worker Launcher" due to administrator command
  2024-06-19 04:00:09.938 UTC [37] LOG:  background worker "TimescaleDB Background Worker Launcher" (PID 43) exited with exit code 1
  2024-06-19 04:00:09.938 UTC [37] LOG:  background worker "logical replication launcher" (PID 44) exited with exit code 1
  2024-06-19 04:00:09.941 UTC [37] LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 55) exited with exit code 1
  2024-06-19 04:00:09.941 UTC [37] LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 64) exited with exit code 1
  2024-06-19 04:00:09.952 UTC [38] LOG:  shutting down
  2024-06-19 04:00:09.955 UTC [38] LOG:  checkpoint starting: shutdown immediate
  .2024-06-19 04:00:11.660 UTC [38] LOG:  checkpoint complete: wrote 1733 buffers (10.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.834 s, sync=0.838 s, total=1.709 s; sync files=769, longest=0.012 s, average=0.002 s; distance=9682 kB, estimate=9682 kB; lsn=0/1E646D0, redo lsn=0/1E646D0
  2024-06-19 04:00:11.927 UTC [37] LOG:  database system is shut down
   done
  server stopped
  PostgreSQL init process complete; ready for start up.
  2024-06-19 04:00:12.115 UTC [1] LOG:  starting PostgreSQL 16.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309, 64-bit
  2024-06-19 04:00:12.115 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
  2024-06-19 04:00:12.115 UTC [1] LOG:  listening on IPv6 address "::", port 5432
  2024-06-19 04:00:12.126 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
  2024-06-19 04:00:12.158 UTC [88] LOG:  database system was shut down at 2024-06-19 04:00:11 UTC
  2024-06-19 04:00:12.375 UTC [1] LOG:  database system is ready to accept connections
  2024-06-19 04:00:12.383 UTC [91] LOG:  TimescaleDB background worker launcher connected to shared catalogs

any thoughts how i can resolve these errors ?