As the name points out the command docker-php-ext-install is meant to install a PHP extension – an .so file. Using PECL is just another way of installing extensions, so, by trying to use docker-php-ext-install after a pecl install you are trying to do twice the same thing.

And as the end of the pecl install points out:

You should add "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so" to php.ini

Which would be what docker-php-ext-enable is meant to do.

So, your working Dockerfile would be:

FROM php:7.4

RUN pecl install xdebug-3.1.5 \
      && docker-php-ext-enable xdebug

This is actually pointed out in the documentation of the php image:

PECL extensions

Some extensions are not provided with the PHP source, but are instead available through PECL. To install a PECL extension, use pecl install to download and compile it, then use docker-php-ext-enable to enable it:

FROM php:7.4-cli
RUN pecl install redis-5.1.1 \
      && pecl install xdebug-2.8.1 \
      && docker-php-ext-enable redis xdebug

Source: https://hub.docker.com/_/php

Answer from β.εηοιτ.βε on Stack Overflow
🌐
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.docker.com › layers › lavoweb › php-7.4 › xdebug › images › sha256-39cb50ca60f5f05e798837afca32a6d7657e95e73d563f3115dd5aa722bafd99
Image Layer Details - lavoweb/php-7.4: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 › pavlakis › docker-xdebug
GitHub - pavlakis/docker-xdebug: Build Xdebug from pecl and pull it in as a docker layer
pavlakis/xdebug:2.4.1 · Each version is installed in a different folder: PHP 8.0 -> /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ PHP 7.4 -> /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ PHP 7.3 -> /usr/local/lib/php/extensions/no-debug-non-zts-20180731/ PHP 7.2 -> /usr/local/lib/php/extensions/no-debug-non-zts-20170718/ PHP 5.6 -> /usr/local/lib/php/extensions/no-debug-non-zts-20131226/ Dockerfile ·
Author   pavlakis
🌐
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%
🌐
Docker
hub.docker.com › layers › bscheshir › php › 7.4.0-fpm-alpine-4yii2-xdebug › images › sha256-54bfb155337cbd4fedc3905459470b30ba51ef6a291d628e257f36f1d4eb88b5
bscheshir/php:7.4.0-fpm-alpine-4yii2-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.
Find elsewhere
🌐
GitHub
gist.github.com › chadrien › c90927ec2d160ffea9c4
Debug PHP in Docker with PHPStorm and Xdebug · GitHub
Having the following env variable living directly in the docker container instance, pointing back to the literal name of the server block, solves the problem. Typically when xdebug first creates a connection, it'll give the server name a default name of _ . you can go change that to whatever you want · PHP_IDE_CONFIG=serverName= ie: name of the server name located in preferences -> languages -> php -> servers ... Great post. Please note that PHP 7.3+ is not compatible with xdebug 2.6 or lower.
🌐
Docker
hub.docker.com › layers › lexasoft › apache-php-xdebug › 7.4 › images › sha256-e29330bde457a5116606c305c8a0c80b88014c11029c535f079416c3e1fbdaad
Image Layer Details - lexasoft/apache-php-xdebug:7.4
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 › 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
🌐
DEV Community
dev.to › krixnaas › debug-in-phplaravel-docker-with-xdebug-2ia6
Debug in PHP/Laravel Docker with xDebug - DEV Community
August 3, 2022 - In those same 2 directories named 7.4 and 8.0, you will find a php.ini file. Open them. ... We need ton configure xdebug. Just add the following in the php.ini file: [XDebug] zend_extension = xdebug.so xdebug.mode = debug xdebug.start_with_request = yes xdebug.discover_client_host = true xdebug.idekey = VSC xdebug.client_host = host.docker.internal xdebug.client_port = 9003
🌐
Docker
hub.docker.com › layers › opensalt › php › 7.4-fpm-xdebug › images › sha256-531d2c03414c2f92936b845a8034183de5daef127bee4019c451ae2946330300
Image Layer Details - opensalt/php:7.4-fpm-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.
🌐
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
🌐
Docker
hub.docker.com › layers › opensalt › php › 7.4.7-fpm-xdebug › images › sha256-7ecac0bb5195b1cc39f00d2c7a968cb733f90a043fc766a4763f67c4fdf337d7
Image Layer Details - opensalt/php:7.4.7-fpm-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.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 4404972605074-Cannot-enable-Xdebug-php-7-4-
Cannot enable Xdebug (php 7.4) – IDEs Support (IntelliJ Platform) | JetBrains
August 10, 2021 - php: image: wodby/drupal-php:$PHP_TAG container_name: "${PROJECT_NAME}_php" environment: PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S espace_rentiers_mailhog:1025 PHP_XDEBUG: 1 PHP_XDEBUG_DEFAULT_ENABLE: 1 PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 PHP_XDEBUG_REMOTE_PORT: 9000 PHP_IDE_CONFIG: serverName=phpstorm PHP_XDEBUG_IDEKEY: "phpstorm" PHP_XDEBUG_REMOTE_HOST: host.docker.internal PHP_XDEBUG_LOG: /var/www/html/xdebug.log volumes: - ./:/var/www/html:cached - ./config/docker-local/settings.local.php:/var/www/html/docroot/sites/default/settings.local.php
🌐
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
🌐
Docker
hub.docker.com › layers › rcompton78 › docker-php-fpm › 7.4-xdebug › images › sha256-a24d7d5287411220475ff1f56ac4ead82a43bb9d81882653931d30ff29920390
rcompton78/docker-php-fpm:7.4-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.
🌐
Docker
hub.docker.com › layers › bscheshir › php › 7.4.0-fpm-4yii2-xdebug › images › sha256-208a81fd47e2c785a3a3fbe6021de61625b73cf47b7ed5514326c13143856a69
Docker
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.