vscode-dev-containers
vscode-dev-containers copied to clipboard
unable to run the `psql` command inside a container that includes Postgres
I am not sure if this is deliberate or not, but I cannot run run the pqsl
command. I get a bash command not found
error.
I have also tried to manually install but would keep getting psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed
as error
I saw a commit here from 2021 of a user claiming to have fixed it and tried to copy the exact same yaml file with no success.
- VSCode Version: 1.67.2
- Local OS Version: Win 11
- Local chip architecture: <x86, arm64, Apple Silicon> arm64
- Reproduces in: Containers
- Name of Dev Container Definition with Issue: Go + PostgresDB
Steps to Reproduce:
- Connect to container
- run the command
Try with postgres
user. su postgres
then psql should work. Also make sure you are executing in database container not go container.
What is the database container? I'm using the "Go & PostgreSQL" Dev container and there is no differentiation.
I tried this command in my bash terminal and I got an error saying there is no user. I then checked the users using "cat /etc/passed" and there is no user names postgres
It actually creates two seperate containers using docker compose. You should have two containers with names similar to myapp_go and myapp_db
Ah I feel stupid thank you. I seem to not be able to access it inside the container even though I can access it via WSL. How would I be able to connect to it inside the container or is that not feasible?
I don't use WSL but it should be possible to run docker commands from bash either from powershell or inside the WSL VM itself. You would use regular exec command to ssh into the container such as docker exec –it mycontainer /bin/bash
.
yh that command I could run inside WSL VM and see my database working. I dont think it be possible to run inside docker
commands work inside VSCode devcontainers, or that I haven't managed to get it working (though I realise this is probably expected behaviour).
cc @idyll @talk2MeGooseman @jarrodldavis as contributors on definitions containing Postgres