-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
questionUsability question, not directly related to an error with the imageUsability question, not directly related to an error with the image
Description
psql -h localhost fails in init scripts. I encountered this problem while running a third party script I can not change.
Simple Dockerfile to reproduce:
FROM postgres:9.4
COPY ./init.sh /docker-entrypoint-initdb.d/
RUN chmod a+x /docker-entrypoint-initdb.d/init.sh
init.sh:
#!/bin/bash
psql -h localhost -p 5432 -U postgres -d postgres -c 'select 1;'
Output:
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
I tried this on windows and linux and with and without the chmod line. The crucial part in the psql command is the -h localhost option. All other options can be removed and the error still occurs, but if the -h is removed everything works fine.
Does a workaround exist for this?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionUsability question, not directly related to an error with the imageUsability question, not directly related to an error with the image