7

I'm running Wordpress (and PHPMyAdmin and MySQL) in a Docker container, and I need to make a change to increase the maximum uploadable file size for PHPMyAdmin

I researched a number of solutions and found a suggestion to create a custom uploads.ini file and then include this file in the docker-compose file.

So I have this:

uploads.ini

file_uploads = On
memory_limit = 64M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 600

docker-compose.yml

version: '3'

services:
  # Database
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    networks:
      - wpsite
  # phpmyadmin
  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - '8080:80'
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: password 
    networks:
      - wpsite
  # Wordpress
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - '8000:80'
    restart: always
    volumes:
      - './:/var/www/html'
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
    networks:
      - wpsite
networks:
  wpsite:
volumes:
  db_data:

I have included the uploads.ini file in the volumes for wordpress

volumes:
      - './:/var/www/html'
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini

But sadly after running the docker-compose and opening localhost:8080 to go to PHPMyAdmin I still only have a maximum file upload size of 2m, not the 64m in my custom file

user1486133
  • 1,309
  • 3
  • 19
  • 37

5 Answers5

5

You want increase the maximum uploadable file size for PHPMyAdmin, but uploads.ini you add for your wordpress container)

add volume for phpmyadmin container and you'll be happy=)

# phpmyadmin
phpmyadmin:
depends_on:
  - db
image: phpmyadmin/phpmyadmin
volumes:
 - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
restart: always
ports:
  - '8080:80'
environment:
  PMA_HOST: db
  MYSQL_ROOT_PASSWORD: password 
networks:
  - wpsite
Agustin Meriles
  • 4,866
  • 3
  • 29
  • 44
Billi Li
  • 69
  • 1
  • 3
2

You can pass the upload limit to the phpmyadmin docker container with an ENV variable

Example

phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
depends_on:
  - mysql
environment:
  - UPLOAD_LIMIT=512M
  - PMA_HOST=mysql
  - PMA_PORT=3306
  - PMA_ARBITRARY=1
ports:
  - "8888:80"
SiParker
  • 56
  • 5
  • 1
    This was the method that worked for me. You just have to stop and start the docker containers afterward. Please note that the syntax was slightly different in my docker-compose.yml file: ` phpmyadmin: image: phpmyadmin/phpmyadmin depends_on: - mysql environment: UPLOAD_LIMIT: 512M PMA_HOST: mysql PMA_PORT: 3306 PMA_ARBITRARY: 1 ` – Lars Ejaas Jan 16 '22 at 19:54
1

You can try to rebuild your image, but like this. Add this somewhere in your your Dockerfile. This way you would be sure its not some kind of permission trouble(which I think it is)

  COPY ./uploads.ini /usr/local/etc/php/conf.d
1

According to this answer you need to set absolute path to mount single file. So add a ${PWD} before files to be mounted.

Your volume part would be like:

volumes:
  - ${PWD}/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
-5

You can use this plugin for the upload max size increase

https://wordpress.org/plugins/upload-max-file-size/

Neal Developer
  • 569
  • 1
  • 4
  • 13