docker-magento: can't enable xdebug, phpfpm container is recreated on restart.
Description
When I try to enable the xdebug with bin/xdebug enable and the phpfpm service is restarted the container is recreated, and the value back to the original state.
- OS: ubuntu.
- Docker version 23.0.1, build a5ee5b1
Steps To Reproduce
- bin/xdebug enable
Expected Result
$ bin/xdebug status
Xdebug debug mode is disabled.
Actual Result
$ bin/xdebug status
Xdebug debug mode is disabled.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 5
- Comments: 24 (5 by maintainers)
@vy-shmal, as a momentary fix to that I change the compose to mount a volume to that php.ini file.
I create the file
./env/php.iniwith the content of the original plus xdebug modifications:And then in the
compose.yamlfile I add a volume…First of all, i made the changes @MaskeZen recommended and after that, still doesnt working.
So after some tests i had to increment some this changes to get all working as expected.
System:
Uncomment these lines in compose.yaml
extra_hosts: - "host.docker.internal:host-gateway"Add this entry on /etc/hosts
172.17.0.1 host.docker.internalobs: To check the host you can paste this on your terminal
docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}'Change server path mapping on phpstorm servers to the “pub” directory, as the screenshot
/var/www/html/pubHope it helps someone!
I’ve been experiencing the same issue on Ubuntu 22.04.2 and, after some research, I’ve found that the issue seems to reside in the
docker composecommand being called inbin/docker-composewhen runningbin/start.To fix the issue I’ve just updated the
bin/docker-composefile as follows:I’m not sure why the
docker composeis behaving differently thandocker-compose, but might as well be a @docker internal issue.Thanks @MaskeZen , you save my time!
Yea I really can’t see why that would be happening, unless the container is completely destroyed when it shuts down.
I don’t think the docker compose thing is any issue at all, as that line should properly return the exact version of docker compose you are running depending on the installed version.
That said, I’m not opposed to creating a new
conf/php.inifile in thecomposedirectory, as this would allow someone to easily edit thephp.inifile right on the host. And since this file is mounted from the local filesystem, it should absolutely persist container restarts. If someone wants to test this out locally, and if it works, make a PR, I’ll take this in.Forgot to attach the output for that one. Here it is:
Confirm same behavior on manjaro linux with Docker Compose version 2.16.0
phpfpm container is recreated and xdebug is never enabled.
If I downgrade to Docker Compose version 2.14.2 then xdebug gets enabled as expected.
@MaskeZen Thanks. I have the same issue and this works with a small change like below. maybe help someone
- ~/.env/php.ini:/usr/local/etc/php/php.ini@MaskeZen Yes it worked for me also, nice thank you.