Php: Include a docker-php-ext-disable

Created on 13 Apr 2016  路  7Comments  路  Source: docker-library/php

I saw that there is no disable script here - ideally, it'd be great to replicate both php5enmod and php5dismod functionality.

I created a disable script based on docker-php-ext-enable and am copying it in my build. The script just looks for the existence of the extension ini file and removes it - but not sure if there is a more ideal way to handle this? Willing to PR it, if there's any interest.

The use case for me was to be able to enable or disable xdebug on the fly when running PHPUnit:

docker exec -ti php sh -c "docker-php-ext-disable xdebug && vendor/bin/phpunit

Most helpful comment

+1 It is useful if you create your own images for dev/prod. If dev extends the production image, it's great to disable something from production, i.e.

# in dev Dockerfile
FROM my-production-image
RUN docker-php-ext-disable opcache

All 7 comments

@kmfk why not add your script as pull request?

I'm honestly a little -1 on adding this. Enabling an extension in a generic way is simple (requires getting extension=xxx.so into the PHP configuration somewhere). Disabling in a fully generic way is not nearly as simple, so I would actually recommend using --ini-name (from https://github.com/docker-library/php/pull/178) to accomplish this more easily.

Yes, furthermore there's no good reason to disable an extension in fact. If you use the same container for tests/dev & production (which is pretty cool), you can imagine running php differently depending on your environment.

It's easier for example to run php php -d 'extension=xdebug.so' myscript.php when developing your app then running just php myscript.php in production.

+1 It is useful if you create your own images for dev/prod. If dev extends the production image, it's great to disable something from production, i.e.

# in dev Dockerfile
FROM my-production-image
RUN docker-php-ext-disable opcache

@kodeart yes... but why not producing a dedicated image for dev and another one for prod? Very easy with automated builds & tags.

@kmfk @tianon I've opened a pull request which introduces docker-php-ext-disable in #270

Given that https://github.com/docker-library/php/pull/178 added --ini-name for explicitly controlling the exact filename docker-php-ext-enable creates (and that the filenames it uses are already trivially deterministic), I'm going to close this with the recommendation that users who need to disable extensions after previously enabling them simply use rm on the appropriate file (or sed, if they've added additional configuration to the file since enabling the extension). Thanks!

Was this page helpful?
0 / 5 - 0 ratings