-
-
Notifications
You must be signed in to change notification settings - Fork 119
symfony cli not setting port for dockerized postgresql db #472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Kinda the same problem here, but with a MySQL Server. I'm debugging this for a few days now, but coming to the conclusion, that the CLI is not detecting the Docker containers. My System:
My compose.yaml: services:
###> doctrine/doctrine-bundle ###
database:
image: mysql:${MYSQL_VERSION:-8.0.33}
volumes:
- ./docker/provision/mysql/init:/docker-entrypoint-initdb.d
environment:
MYSQL_DATABASE: ${MYSQL_DATABASE:-app}
MYSQL_ROOT_PASSWORD: root
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-!ChangeMe!}
MYSQL_USER: ${MYSQL_USER:-app}
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 5s
retries: 10
ports:
- "3306:3306"
###< doctrine/doctrine-bundle ### I can connect to the database, but have to bind the port statically. Ideally you could just set "ports: [ 3306 ]" and the CLI would automatically pick up the port set by Docker, right? Also the web profiler indicates, that Docker is not running: Note, that in the latest version of Docker, the Also: Docker Desktop sets the unix socket on |
This is unlikely as we directly use the Go library from Docker Compose and do not rely on the
We rely on the Docker official source code for this (see above). So if the Lines 72 to 91 in 37bdf46
To debug, you should be able to use |
I can confirm, that this problem still exists:
It returns the following (first two lines added by me):
The daemon and container was running when I executed:
I think not. I posted my compose file above. Since then I didn't changed anything about it, so you can double check, if you want. |
Looks like the solution... Sadly I'm missing the "Advanced" tab in my Docker Desktop app - probably an error on dockers side. |
It seems like there is currently a bug in Docker Desktop, where the "Advanced" tab might be not appear for some users (see docker/for-mac#7127). For anybody, who has the same problem, can use the following fix for now:
The Symfony CLI does pick up the @naturefund-falk you might want to check your configured Docker endpoint ( |
The solution from @ebitkov seems to work that way. My docker context ls output is:
So i used the rootless socket for the DOCKER_HOST variable and the warning in (symfony var:export -v=5 --debug) about not connecting to docker is gone. |
Just dropping in here that I had a similar but slightly different problem. For anyone who tries these things but sees #551 is looking to add more detection methods which would hopefully make this misconfiguration issue less likely to occur. |
I'm having this exact issue. I don't totally get it, but i removed the .git folder from the symfony directory as it lives in a larger project. Sadly everything worked well on previous days but i cannot get it to work now. Any ideas would be appreciated! |
Unfortunately, as my comment explains, the .git repository is how Symfony CLI detects the Otherwise, with the current version, you'll have to turn your Symfony CLI into its own git project and then include it in the larger one as a submodule. |
Oh, actually, the git repo change was recent. Use a version of the CLI from before a month ago and you should go back to old behavior. |
See #555 |
I created a new symfony (7.0.7) webapp, created an entity and wanted to run symfony console doctrine:database:create. Output:
An exception occurred in the driver: 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?
Apparently the port number is wrong here. As i understood the symfony command, it should detect the real port number of the postgres container and then call the doctrine:database:create command. But it seems this is not happening. Running 'symfony run printenv' does not print anything related to the database.
The database is running inside docker (status=unhealthy, but running 'pg_isready -U ${POSTGRES_USER:-app}' inside the container is running ok and no error messages in logs).
Docker 26.1.1 is installed in rootless mode on a debian 12 system.
Symfony cli version is 5.8.16.
The text was updated successfully, but these errors were encountered: