How to containerize a php cli application🔗
Dockerfile🔗
Start from an existing php image:
1 | |
Install required packages (optional):
1 2 3 | |
Install or enable an already installed php extension (optional):
1 2 | |
Or with PECL:
1 | |
Install the php command you want, could be downloading a phar for exemple:
1 | |
Define endpoints:
1 | |
More on Docker Official Images documentation.
Build the container🔗
1 | |
Usage🔗
1 | |
If you need to access to the host filesystem, you will need to mount volumes:
1 | |
Last update: October 14, 2025