Php in docker in order to be able to set up quickly a dev environment with debugging capability
449
This is a docker image that I use as development environment with:
The important configuration is the host in the php.ini.
This configuration is where xdebug should send its data.
The value is now set to the docker host
# xdebug version 2 (image 7.2)
xdebug.remote_host=host.docker.internal
# xdebug version 3 (image 7.4)
xdebug.client_host=host.docker.internal
If your docker setup uses another name or ip to contact your ide (laptop), you need to change this configuration and restart the container.
You can test the connection from the container to your laptop with the following command
docker exec -it containerName bash
apt-get install -y nmap
nmap -Pn -p T:9000 host.docker.internal
The output should show that the port is open.
A whole article is available here: PHP - (Debug|Debugger) with Xdebug in Docker
Short version:
/var/www/html. For instance:REM in a DOS Shell
cd YourApplication
docker run ^
--name myapp ^
-d ^
-p 80:80 ^
-v %cd%:/var/www/html ^
gerardnico/php-dev:7.4
# in Powershell
cd YourApplication
docker run `
--name myapp `
-d `
-p 80:80 `
-v ${pwd}:/var/www/html `
gerardnico/php-dev:7.2
docker exec -ti $(CONTAINER) /bin/bash
Content type
Image
Digest
Size
202.4 MB
Last updated
over 6 years ago
docker pull gerardnico/php-dev