| Property | Value |
|---|---|
| Severity | Warning |
| Category | Best Practices |
| Default | Enabled |
| Auto-fix | Yes (comment-out as suggestion, delete as unsafe) |
Description
Flags Xdebug installations in the final image stage. Xdebug is a PHP debugging and profiling tool designed for development workflows. Shipping it in production images degrades performance, increases image size, and widens the attack surface. The rule detects:docker-php-ext-install xdebugdocker-php-ext-enable xdebugpecl install xdebug(including versioned forms likexdebug-3.4.0)- Package manager installs containing xdebug (
apt-get install php-xdebug,apk add php-pecl-xdebug, etc.) - Observable scripts (COPY heredoc, build context) that install Xdebug
dev, development, test, testing, ci, or debug are skipped. Only the final stage is checked — intermediate builder
stages are expected to have development tooling.
Examples
Before
After
Move Xdebug into a dedicated development stage:Fix behavior
When the entire RUN instruction only installs or enables Xdebug, two alternative fixes are offered:- Comment out (suggestion, preferred): Prefixes each line with
#. - Delete (unsafe): Removes the instruction entirely.
docker-php-ext-install gd xdebug intl), no auto-fix is offered — the rule
reports the violation for manual resolution.