V
V
Vadim Timoshenko2022-01-16 19:06:12
PostgreSQL
Vadim Timoshenko, 2022-01-16 19:06:12

How to set up Symfony CLI to work with psql in docker?

I am using WSL2 on Ubuntu. VS Code editor.
I execute commands to Symfony using Symfony CLI.

I access psql, which is in the docker container like this:
symfony run psql

.. to which I get the answer: I guess from the message that the problem is in the path to psql. But where to look for and change it, and how to forward the path to psql to the container from WLS? Now I write commands through: .. but I want to be simpler. Please send.
exec: "psql": executable file not found in $PATH


docker-compose exec database psql -U main

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2022-01-17
@ky0

which psql
Then you can just add a link to the binary to /usr/bin: ln -s /usr/local/something/bin/psql /usr/bin/psql
All this is true if you are accessing a database located on the same machine. If not, open the port and connect over the network.

M
Maxim Popov, 2022-02-01
@maxomato

if psql is needed to just execute the query,
then you can do this

symfony console dbal:run-sql 'select * from tablename'

so you do not need to enter a password, user and database name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question