Skip to content
Advertisement

Docker Compose: Set variable in php.ini from Dockerfile

I have a small Docker network based on this package for Docker Compose and Laravel. I’d like to set the upload_max_filesize and post_max_size variables in php.ini to allow for larger file uploads.

Is this possible? Or is there an alternative approach? I expected to find lots of similar questions on the web, but it’s not that many and typically they concern some existing image, while I create the PHP image from a Dockerfile.

This is from docker-compose.yml:

php:
  build:
    context: .
    dockerfile: php.dockerfile
  container_name: php
  volumes:
    - ./src:/var/www/html
  ports:
    - "9000:9000"
  networks:
    - laravel

This is php.dockerfile

FROM php:7.4-fpm-alpine

WORKDIR /var/www/html
 
RUN apk add --no-cache zip libzip-dev
RUN docker-php-ext-configure zip
RUN docker-php-ext-install zip

RUN docker-php-ext-install pdo pdo_mysql

Advertisement

Answer

You can create your own php.ini locally and COPY it in your dockerfile for instance.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement