Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 332
Pida Avatar asked Nov 01 '25 10:11

Pida


2 Answers

Here is a sample of overriding some php.ini values instead of editing the php.ini directly. enter image description here

enter image description here

like image 135
Abdullahi Abdulkabir Avatar answered Nov 03 '25 03:11

Abdullahi Abdulkabir


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

like image 35
Michée Lengronne Avatar answered Nov 03 '25 02:11

Michée Lengronne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!