I solved this by adding the following lines into my Docker file:

# "xdebug-2.9.0" for PHP<=7.4 — "xdebug" (3) for PHP>=8
ARG XDEBUG_VERSION="xdebug-2.9.0"

FROM php:7.0-apache

RUN a2enmod rewrite

RUN docker-php-ext-install pdo pdo_mysql

RUN yes | pecl install ${XDEBUG_VERSION} \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini


COPY php.ini /usr/local/etc/php/
COPY . /var/www/html/
Answer from UrmLmn on Stack Overflow
Discussions

laravel - How to enable xdebug in php:7.4-fpm-alpine docker container? - Stack Overflow
My target is to use this git repo for Laravel with xdebug for php-fpm: https://github.com/aschmelyun/docker-compose-laravel When using this repo i run: docker-compose up -d --build site docker-com... More on stackoverflow.com
🌐 stackoverflow.com
php - Configure Xdebug in Docker container - Stack Overflow
I'm trying to create a docker container with PHP and Xdebug to use step debugging. I use VSCode and somehow this debugger it's not working. Apparently the Dockerfile is not been executed when I use More on stackoverflow.com
🌐 stackoverflow.com
phpstorm - Xdebug CLI in Docker - Stack Overflow
I read a lot of posts on GitHub and StackOverflow and I didn't find an answer. I have Docker container with PHP 7.4 and Xdebug 3. The IDE is PhpStorm. When I use Xdebug in browser, Xdebug works fin... More on stackoverflow.com
🌐 stackoverflow.com
Where is Xdebug for PHP 8.4?
You can find an update from Derick from the start of the month here (5th November): https://derickrethans.nl/xdebug-update-october-2024.html In that he states: I made the first beta release of Xdebug 3.4 that is compatible with PHP 8.4, which is due to be released on November 21st. I hope to have a GA release of Xdebug 3.4.0 out around that date too. So he might just be a bit behind that original target, give him a little time. I also found a roadmap in the bugtacker targeting the 29th, but not sure how representative of any intentions that is. Is it just one guy working on one of the most widely used debugging extensions for PHP? For the most part , make sure to donate to support Derick's work if able! More on reddit.com
🌐 r/PHP
32
46
November 27, 2024
🌐
Docker
hub.docker.com › layers › ekreative › php › 7.4-rc-xdebug › images › sha256-135f2844256cc490c838eda532de43f7d391869e618a498e22b7ba5a215538ed
Image Layer Details - ekreative/php:7.4-rc-xdebug
Welcome to the world's largest container registry built for developers and open source contributors to find, use, and share their container images. Build, push and pull.
🌐
GitHub
github.com › sineverba › php74xc
GitHub - sineverba/php74xc: Docker image for PHP7.4 with Xdebug and Composer
Docker image built from PHP7.4.x CLI official + Xdebug + Composer, multiarchitectures.
Forked by 2 users
Languages   Makefile 67.3% | Dockerfile 32.7% | Makefile 67.3% | Dockerfile 32.7%
🌐
Docker Hub
hub.docker.com › r › p1xel › ubuntu-php7-xdebug › dockerfile
p1xel/ubuntu-php7-xdebug Dockerfile
Welcome to the world's largest container registry built for developers and open source contributors to find, use, and share their container images. Build, push and pull.
🌐
Medium
medium.com › @adev95 › install-xdebug-for-php-7-on-docker-3e47b3e5de9c
Install XDebug for PHP 7 on Docker 🪲 | by Adev95 | Medium
October 3, 2023 - pecl channel-update pecl.php.net pecl install xdebug-2.7.2 \ && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \ && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ && echo "xdebug.remote_autostart=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/xdebug.ini \ && echo "xdebug.remote_port=9596" >> /usr/local/etc/php/conf.d/xdebug.ini
Find elsewhere
🌐
GitHub
gist.github.com › patricknelson › 57ae24986cb13613314fb1f3c00a95d7
Using Xdebug in Docker (works with PhpStorm) · GitHub
Ensure you've got XDebug installed and enabled in your PHP docker image, for example: # Installing Xdebug with PHP 7.3 images: RUN pecl install xdebug \ && docker-php-ext-enable xdebug
🌐
GitHub
gist.github.com › chadrien › c90927ec2d160ffea9c4
Debug PHP in Docker with PHPStorm and Xdebug · GitHub
Hi, On linux with firewalld enabled, the container hasn't route for host, so it not attach to host port 9000 (xdebug). The route can be add by: firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="172.17.0.0/16" accept' Where 172.17.0.0 is docker container's subnet (check it with ifconfig). ... This will need to be updated for php 7.4, see: https://olvlvl.com/2019-06-install-php-ext-source , pecl won't be available in the php base image.
🌐
GitHub
github.com › mobtitude › docker-php-xdebug
GitHub - mobtitude/docker-php-xdebug: Docker images with PHP and xdebug installed, configured and ready to debug and profile applications in modern IDEs. · GitHub
Q: Why images don't have specific PHP version like 7.2.2 but only major and minor version 7.2? A: It is because images in this repo have always the newest possible patch version of PHP based on official Docker PHP images. For example for mobtitude/php-xdebug:7.2-apache you can expect that it is always the newest PHP version available in official Docker Registry and it is automatically updated when official PHP Docker images are updated.
Starred by 20 users
Forked by 8 users
Languages   Dockerfile 61.9% | Shell 31.6% | Makefile 3.7% | PHP 2.8%
🌐
GitHub
github.com › maciejslawik › docker-php-fpm-xdebug › blob › master › Dockerfile
docker-php-fpm-xdebug/Dockerfile at master · maciejslawik/docker-php-fpm-xdebug
RUN echo 'alias xon="mv /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini.off /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && kill -USR2 1"' >> ~/.bashrc · · # Change memory limit · RUN echo 'memory_limit = 2G ' >> /usr/local/etc/php/php.ini · · # Install Blackfire probe - no version for 7.4 available yet ·
Author   maciejslawik
🌐
Matthew Setter
matthewsetter.com › setup-step-debugging-php-xdebug3-docker
Setup Step Debugging in PHP with Xdebug 3 and Docker Compose | Blog - Matthew Setter. Accessible Web App Developer, Educator, and Author, based in Bundaberg, Queensland.
March 10, 2021 - The php container uses a custom Dockerfile (./docker/php/Dockerfile) to define its build steps, which you can see in the example below. This is because Xdebug doesn't come "bundled" with the official Docker Hub PHP containers. FROM php:7.4-fpm RUN pecl install xdebug \ && docker-php-ext-enable xdebug
🌐
Peterbabic
peterbabic.com › blog › php-xdebug-in-docker
Peter Babič - PHP xDebug in Docker
February 23, 2025 - Whatever you Dockerfile contents are, add these somewhere sensible, before EXPOSE or COPY usually: RUN apk add --no-cache $PHPIZE_DEPS linux-headers && \ pecl install xdebug && docker-php-ext-enable xdebug
🌐
Medium
medium.com › @bobillie › installer-php-xdebug-sur-une-image-docker-php-7-4-apache-cafbaf0c8037
Installer PHP Xdebug sur une image docker php:7.4-apache | by Michel Bobillier | Medium
February 3, 2023 - Le problème provient que les dernières version de Xdebug ne supporte plus le PHP 7.4, la solution est de forcer la version de Xdebug à installer, pour cela j’ai corriger mon Dockerfile
🌐
Stack Overflow
stackoverflow.com › questions › 73529501 › configure-xdebug-in-docker-container
php - Configure Xdebug in Docker container - Stack Overflow
My OS is Ubuntu 20.04.5 LTS; Dockerfile, docker-compose.yml and 90-xdebug.ini are in project's root. My Dockerfile: FROM php:7.4-apache COPY 90-xdebug.ini "/usr/local/etc/php/conf.d" RUN pecl install xdebug RUN docker-php-ext-enable xdebug · 90-xdebug.ini: xdebug.mode=debug xdebug.discover_client_host=0 xdebug.client_host=host.docker.internal ·
🌐
Chris Shennan
chrisshennan.com › blog › fixing-pecl-xdebug-requires-php-version-8-installed-version-7-4
Fixing: pecl/xdebug requires PHP (version >= 8.0.0, version <= 8.3.99), installed version is 7.4.33 | Chris Shennan
January 11, 2023 - If upgrading to PHP 8 is not an option, you can install an earlier version of Xdebug onto your PHP7 environment · chris@chris-xps:~$ docker run --rm -it php:7.4 bash root@aeb100b038dd:/# pecl install xdebug-3.1.5 ... ... output from build steps ...
🌐
Thecodingmachine
thecodingmachine.io › configuring-xdebug-phpstorm-docker
Debugging PHP (web and cli) with Xdebug using Docker and PHPStorm
To follow this tutorial, you must have the Xdebug extension installed on your container. In my example, I will use a Docker image of TheCodingMachine created by David Négrier. If you are starting a project, I recommend you to download one of our images here TheCodingMachine Docker PHP images ... app: image: thecodingmachine/php:7.2-v1-apache volumes: - .:/var/www/html environment: PHP_EXTENSION_XDEBUG: 1