Closed
Description
When I run symfony console
, Symfony CLI does not detect my docker compose containers. The error happens when there is no .git
directory in the Symfony project directory.
- Ubuntu 22.04 LTS
- Docker 27.3.1
- Symfony CLI version 5.10.5
How to reproduce
mkdir sf-git-producer
cd sf-git-producer
git init .
symfony new --no-git --webapp inner
cd inner
docker compose up -d
symfony console doc:query:sql 'SHOW TABLES'
This command returns an error because there is no git directory.
Actual output
SQLSTATE[08006] [7] connection to server at "127.0.0.1", port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
Expected result
I would expect it to try connecting to a different server & port, according to DATABASE_URL
.
When I run symfony serve
, the profiler toolbar indicates no database/mailpit. symfony run env
shows no special environment variable for the database.
Workaround
I workaround by running git init
before any symfony command:
# run this before your command to fix the problem
git init .
symfony console doc:query:sql 'SHOW TABLES'
# delete to break future execution
rm -rf .git
Final note
Don't forget to cleanup:
docker compose down
Metadata
Metadata
Assignees
Labels
No labels