DEV Community

Cover image for Increase WordPress uploads limit in Docker
Thomas Rigby
Thomas Rigby

Posted on • Originally published at thomasxbanks.com on

Increase WordPress uploads limit in Docker

I've recently moved over to using Docker to manage my WordPress builds. It has many advantages and, the more comfortable I get, relatively few disadvantages. Not sponsored or anything, it's just boss!

One thing I find happens every single time is trying to upload an image into the Media Library and getting the "filename exceeds the maximum upload size for this site" error.

Alt Text

Inevitably, I find myself sticking docker wordpress increase upload limit into Bing (yes, Bing). There are a few answers knocking around - some of which I can get to work, some of which I can't.

This is the solution that I find works for me. I'm posting it here to save myself an hour of Googling next time! 😅

Step 1: uploads.ini

Firstly, create an uploads.ini file in your project. I like to keep mine in a specific config folder with my .htaccess file.

Step 2: Add your options

In the uploads.ini file, add the following:

upload_max_filesize = 16M
post_max_size = 24M
Enter fullscreen mode Exit fullscreen mode

Feel free to change the values to suit your needs.

Step 3: Include your file

The file now needs mounting using volumes.

If you're using docker-compose, it will look a little something like this:

version: '3.1'

services:
  wordpress:
    image: wordpress:5.7.0-php7.3-apache
    restart: always
    ports:
      - 80:80
    environment:
    volumes:
      - ./config/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
      - ./www/themes:/var/www/html/wp-content/themes:delegated
      - ./www/plugins:/var/www/html/wp-content/plugins:delegated

volumes:
  wordpress:
Enter fullscreen mode Exit fullscreen mode

And that's it!

Start or restart Docker and you'll no longer get nasty errors when you try to upload that massive photo.

Just be aware that upload limits exist for good reason - nobody wants to have to download a tonne of 10Mb 1920×1080 images that are only going to be used as 300px thumbnails…

Top comments (0)