Open Kanezal opened 2 months ago
You should be able to access PostgreSQL directly but if still didn't work, please check the environment variables exported within your dev container here.
Hi @itsmechlark I had similar issue too. After setting up the postgresql service, I tried to login but got prompted for passoword. I tried vscode
, codespace
, and postgres
but wasn't authenticated cause it was incorrect. I even add sudo
at the front of psql -U postgres
and still have to input password
Please do you mind telling me what I might not be doing well?
My devcontainer.json
{
"features": {
"ghcr.io/itsmechlark/features/postgresql:1.5.0": {}
}
}
This is what I later did. I had to modified the pg_hba.conf file
.devcontainer/setup-postgres.sh
#!/usr/bin/env bash
# Get version number
major_version_number=$(psql --version | cut -d' ' -f3 | cut -d'.' -f1)
# Path to the pg_hba.conf file
PGHBA_CONF="/etc/postgresql/${major_version_number}/main/pg_hba.conf"
# Backup the original configuration file
cp $PGHBA_CONF ${PGHBA_CONF}.bak
# Modify the pg_hba.conf file to use 'trust' authentication
cat <<EOF > $PGHBA_CONF
# Database administrative login by Unix domain socket
local all all trust
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
EOF
# Restart PostgreSQL to apply changes
sudo service postgresql restart
echo "PostgreSQL configuration updated and service restarted."
.devcontainer/devcontainer.json
{
"name": "PostgreSQL Playground",
"features": {
"ghcr.io/itsmechlark/features/postgresql:1.5.0": {}
},
"postCreateCommand": "sudo bash .devcontainer/setup-postgres.sh"
}
setup this repo to my github codespace in devcontainer.json, in features. Also restart postgresql service to run postgres. So, what the postgres user password? How can I manage it?