You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The pgstac docker entrypoint has a process_init_files function that can run or source shell scripts or run psql files using the docker_process_sql as a drop-in replacement for the psql command.
Before this command is run, a temporary server is started with the docker_temp_server_start function which starts the server at a socket. docker_process_sql ensures that psql connects to the socket by setting PGHOST and PGHOSTADDR to be empty:
If the shell script is run (not sourced) and if the shell script contains the psql command, then PGHOST and PGHOSTADDR are not set to be empty for the psql command in the shell script (which is run in a subprocess). This means that if PGHOST and PGHOSTADDR are set to anything other than empty, psql will try to connect to a probably non-existent host and will fail.
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 ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
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.
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
waiting for server to start....2024-11-18 20:41:43.500 UTC [47] LOG: starting PostgreSQL 15.7 (Debian 15.7-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2024-11-18 20:41:43.502 UTC [47] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-11-18 20:41:43.506 UTC [50] LOG: database system was shut down at 2024-11-18 20:41:42 UTC
2024-11-18 20:41:43.510 UTC [47] LOG: database system is ready to accept connections
done
server started
CREATE DATABASE
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-preinitdb.d/*
2024-11-18 20:41:43.720 UTC [47] LOG: received fast shutdown request
waiting for server to shut down....2024-11-18 20:41:43.722 UTC [47] LOG: aborting any active transactions
2024-11-18 20:41:43.724 UTC [47] LOG: background worker "logical replication launcher" (PID 53) exited with exit code 1
2024-11-18 20:41:43.725 UTC [48] LOG: shutting down
2024-11-18 20:41:43.726 UTC [48] LOG: checkpoint starting: shutdown immediate
2024-11-18 20:41:43.905 UTC [48] LOG: checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.040 s, sync=0.134 s, total=0.180 s; sync files=301, longest=0.004 s, average=0.001 s; distance=4215 kB, estimate=4215 kB
2024-11-18 20:41:43.912 UTC [47] LOG: database system is shut down
done
server stopped
waiting for server to start....2024-11-18 20:41:43.958 UTC [64] LOG: starting PostgreSQL 15.7 (Debian 15.7-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2024-11-18 20:41:43.960 UTC [64] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-11-18 20:41:43.964 UTC [67] LOG: database system was shut down at 2024-11-18 20:41:43 UTC
2024-11-18 20:41:43.969 UTC [64] LOG: database system is ready to accept connections
done
server started
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/990_pgstac.sh
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
Is the server running on that host and accepting TCP/IP connections?
The text was updated successfully, but these errors were encountered:
The pgstac docker entrypoint has a
process_init_files
function that can run or source shell scripts or run psql files using thedocker_process_sql
as a drop-in replacement for thepsql
command.Before this command is run, a temporary server is started with the
docker_temp_server_start
function which starts the server at a socket.docker_process_sql
ensures thatpsql
connects to the socket by settingPGHOST
andPGHOSTADDR
to be empty:pgstac/docker/pgstac/dbinit/docker-entrypoint.sh
Line 197 in 6c569c0
If the shell script is run (not sourced) and if the shell script contains the
psql
command, thenPGHOST
andPGHOSTADDR
are not set to be empty for thepsql
command in the shell script (which is run in a subprocess). This means that ifPGHOST
andPGHOSTADDR
are set to anything other than empty,psql
will try to connect to a probably non-existent host and will fail.STEPS TO REPRODUCE
This works fine:
The same command with the
PGHOST
environment variable set:results in the following logs:
The text was updated successfully, but these errors were encountered: