install packages from docker-compose.yml into docker container
To get a PHP docker container with the intl extension, you need to extend the official PHP image.
To do so, declare the use of your own Dockerfile
for your PHP image in docker-compose.yml
:
services: php: # Remove this line # image: php:7-fpm # Add this one instead build: './docker/php' # ...
Then, add the following Dockerfile
file to the docker/php
folder:
FROM php:7.1-fpmRUN apt-get update && apt-get install -y \ libicu-dev \ && docker-php-ext-install \ intl \ && docker-php-ext-enable \ intl
You can now run docker-compose build
to get your PHP container built with the Intl extension.
A few notes:
- I prefer to explicitly tell which PHP version I use (here "7.1.x") rather than the more generic "7.x" you defined with
php:7-fpm
. - I preferred to use the
docker-php-ext-install
anddocker-php-ext-enable
command utilities provided by the PHP official image (see "How to install more PHP extensions" section in the PHP image documentation).