Wordpress Docker won't increase upload limit
Asked Answered
D

12

89

I am trying to increate the upload limit of my Dockerized Wordpress instance to 150M.

[filename] exceeds the maximum upload size for this site.

I have created an uploads.ini file and attached it by volume to the instance. Yet I still can't get the Wordpress media uploader to increase it's limit.

Docker-compose.yml:

version: '2'
services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: password1
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: password1

   wordpress:
     depends_on:
       - db
     build: ./wordpress
     ports:
       - "8085:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_PASSWORD: password1
     volumes: 
       - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini 
volumes:
    db_data:

uploads.ini:

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

Docker inspect on container:

[
    {
        "Id": "8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f",
        "Created": "2017-03-15T23:47:54.480206792Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "apache2-foreground"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 15956,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2017-03-16T17:46:30.075247017Z",
            "FinishedAt": "2017-03-16T17:46:29.700791339Z"
        },
        "Image": "sha256:cfe94722592e66629527d7fc1546174916c758c6945eb9911506077e76c4d00e",
        "ResolvConfPath": "/var/lib/docker/containers/8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f/hostname",
        "HostsPath": "/var/lib/docker/containers/8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f/hosts",
        "LogPath": "/var/lib/docker/containers/8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f/8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f-json.log",
        "Name": "/edgeofrevolt_wordpress_1",
        "RestartCount": 0,
        "Driver": "aufs",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": [
            "8efe40659ebd3e44b17d45f1dd2aac20f12e13a4513e41520d6c2a1b1f01aa08"
        ],
        "HostConfig": {
            "Binds": [
                "/root/NginxDockerProxyPass/edgeofrevolt/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini:rw",
                "374db2645434a23b92074b6d95935361948397519f2d5a531986bb925ceb0f53:/var/www/html:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "edgeofrevolt_default",
            "PortBindings": {
                "80/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8085"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "always",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": -1,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0
        },
        "GraphDriver": {
            "Name": "aufs",
            "Data": null
        },
        "Mounts": [
            {
                "Source": "/root/NginxDockerProxyPass/edgeofrevolt/uploads.ini",
                "Destination": "/usr/local/etc/php/conf.d/uploads.ini",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Name": "374db2645434a23b92074b6d95935361948397519f2d5a531986bb925ceb0f53",
                "Source": "/var/lib/docker/volumes/374db2645434a23b92074b6d95935361948397519f2d5a531986bb925ceb0f53/_data",
                "Destination": "/var/www/html",
                "Driver": "local",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "8edc91a51bf8",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "affinity:container==6797730d5702955f114fd260628b82615aa7702d0cafae7dae456b1806009437",
                "WORDPRESS_DB_HOST=db:3306",
                "WORDPRESS_DB_PASSWORD=p0kem0n2468Y",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "PHPIZE_DEPS=autoconf \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkg-config \t\tre2c",
                "PHP_INI_DIR=/usr/local/etc/php",
                "APACHE_CONFDIR=/etc/apache2",
                "APACHE_ENVVARS=/etc/apache2/envvars",
                "PHP_EXTRA_BUILD_DEPS=apache2-dev",
                "PHP_EXTRA_CONFIGURE_ARGS=--with-apxs2",
                "PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2",
                "PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2",
                "PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie",
                "GPG_KEYS=0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3",
                "PHP_VERSION=5.6.30",
                "PHP_URL=https://secure.php.net/get/php-5.6.30.tar.xz/from/this/mirror",
                "PHP_ASC_URL=https://secure.php.net/get/php-5.6.30.tar.xz.asc/from/this/mirror",
                "PHP_SHA256=a363185c786432f75e3c7ff956b49c3369c3f6906a6b10459f8d1ddc22f70805",
                "PHP_MD5=68753955a8964ae49064c6424f81eb3e",
                "WORDPRESS_VERSION=4.7.2",
                "WORDPRESS_SHA1=7b687f1af589c337124e6247229af209ec1d52c3"
            ],
            "Cmd": [
                "apache2-foreground"
            ],
            "Image": "edgeofrevolt_wordpress",
            "Volumes": {
                "/usr/local/etc/php/conf.d/uploads.ini": {},
                "/var/www/html": {}
            },
            "WorkingDir": "/var/www/html",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "da7c1855141bc762874ddd4734f2b062556a041750ff48a3cfa3954bb7dfed6c",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "edgeofrevolt",
                "com.docker.compose.service": "wordpress",
                "com.docker.compose.version": "1.8.1"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "ceec8d1498a6988b4cc56ad10afa5cf87e0670d030460efbd26bd5ace185a375",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "8085"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/ceec8d1498a6",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "edgeofrevolt_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "wordpress",
                        "8edc91a51bf8"
                    ],
                    "NetworkID": "89bde3d402cc2fe938279c30415cc2947f92205e610dff1acba69101440b90e7",
                    "EndpointID": "916db2fab99a1637aef87aa1f05fb702fb9b6d3692bf04a9bf46bf122fe9e990",
                    "Gateway": "172.23.0.1",
                    "IPAddress": "172.23.0.3",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:17:00:03"
                }
            }
        }
    }
]

EDIT: there was a typo in 'upload_max_filesize'

Dismissive answered 23/3, 2017 at 17:42 Comment(3)
For reference, this is a continuation of an issue discussion: github.com/docker-library/wordpress/issues/…Pluton
@Gant yeah I'm the latest post on that. I actually created this post to not flood that post anymore. People there have it working. Hoping one of them hits me back. I exhausted all the available options to me in that thread :/Dismissive
@Gant do have anymore insight, I'm getting any help unfortunately :/Dismissive
D
24

I discovered my problem.

docker-compose kill will kill a container but rebuild it from a cache. Meaning no changes to my files were taking place.

Use docker-compose up -d --build

Dismissive answered 5/4, 2017 at 17:56 Comment(1)
you could use docker-compose up -d --buildPentaprism
F
148

it worked for me as follows: i created uploads.ini alongside of docker-compose.yml with following lines. this is exactly how it stated in fist post.

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

after this i added

volumes: 
   - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini

to my .yml file as it states in first post.

after this i had to delete the container/images (basically start from scratch):

docker stop [image name]
docker rm [image name]
docker image rm [image name]

some places i end up using ID insted of image name. name or ID basically you have to stop, remove container and image. bottom line is start from scratch with additional line in your .yml file as describe in first post. remember, you'll lose all your wp work. now run

docker-compose up -d --build

upload limit should be increased now. i was able to upload my new bigger theme after this change. no more upload file size error. only question is if you need to increase this upload size limit in the middle of your work then how would you do this?...

Fluke answered 2/1, 2019 at 20:59 Comment(5)
careful there is also a cache and sometimes your volume will persist if you try to start from scratch again. Docker volumes are not deleted when you delete your container at least not at the time when I wrote this post. I have a few Wordpress sites up now and I've done some crazy large uploads. Read the Wordpress documentation or Apache documentation to understand the issue with doing this in the middle of development.Dismissive
the uploads.ini is a good idea, but you can restart the container with just docker-compose up -d; you don't need to rebuild or remove running containersLoesceke
This worked for me over the preferred answer. 04.10.2019Asylum
This worked, but when I connect with bash to the container and browse to /usr/local/etc/ I don't see a php folder. Why is that and how is it working?Chimpanzee
If you are using NGINX, remember to modify default.conf file like this : server { ... client_max_body_size 500M; ... }Voile
E
42

I prefer to adjust .htaccess for my own workflow. Last 2 lines are what I added

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

php_value upload_max_filesize 500M
php_value post_max_size 500M

then restart

docker-compose down --volumes
docker-compose up -d

Enjoy )

Ear answered 4/12, 2020 at 2:9 Comment(4)
I didn't even have to restart the container.Restrict
This is the simple and best solution. ThanksLakshmi
It works like a charm. Don't even need to restart the containerEdinburgh
This should 100% be the correct answer; way simpler.Atchison
D
24

I discovered my problem.

docker-compose kill will kill a container but rebuild it from a cache. Meaning no changes to my files were taking place.

Use docker-compose up -d --build

Dismissive answered 5/4, 2017 at 17:56 Comment(1)
you could use docker-compose up -d --buildPentaprism
S
23

Just add these two lines to then end of your .htaccess file :

php_value upload_max_filesize 500M
php_value post_max_size 500M

You don't even need to restart the container

Sporran answered 11/12, 2021 at 20:44 Comment(2)
Thank you so much. I solved this issue following your advice.Barmen
This is the easiest, cleanest route in my opinion.Mame
D
3

This solution solves the problem via a Dockerfile:

I modified my docker-compose.yml in the following way when I brushed up against the PHP file upload limit issue:

First I created uploads.ini:

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

Next I created Dockerfile-php:

FROM wordpress:5.8.2
COPY ./uploads.ini /usr/local/etc/php/conf.d

Finally, I added build config in the wordpress part of docker-compose.yml to reference Dockerfile-php which in turn referenced uploads.ini:

  wordpress:
    build:
      context: .
      dockerfile: Dockerfile-php
    depends_on:
      - db
    image: wordpress:5.8.2
   <snippity snip>

Then, while in the docker-compose directory with all my files:

docker rm [containerName]
docker-compose build --no-cache
docker-compose up -d

(I know --no-cache in the build command above is redundant if we've already deleted the legacy container(s); just good practice to ensure we always read the latest changes)

I was now able to successfully upload the files previously failing due to the PHP limit restriction.

Dextrosinistral answered 6/1, 2022 at 10:38 Comment(0)
A
2

The best option would be to execute the command:

docker-compose down && docker-compose up -d --build

docker-compose kill, in this case the process itself is killed, this is not entirely correct.

Appeasement answered 5/6, 2020 at 14:28 Comment(0)
G
2

I didn't create an 'uploads.ini' file but an 'upload.ini' file and added it, as mentioned, alongside with the docker-compose.yaml file. then I did bind it as mentioned in the docker-compose.yaml file :

volumes:
  - ./upload.ini:/usr/local/etc/php/conf.d/uploads.ini

and then I ran docker compose up --build and It worked !!

Garton answered 3/2, 2023 at 17:58 Comment(0)
C
1

There is a typo in your uploads.ini

upload_max_fileszie => upload_max_filesize

Crux answered 1/5, 2017 at 12:44 Comment(1)
It does not apply, or maybe it was edited after your post. Anyway, this reply is out of context. Suggest to check this official guide (stackoverflow.com/help/article-feedback) to see expected collaboration waysAgitate
L
1
version: '2'
services:
  db:
    image: mysql:latest
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password1
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: password1
    networks:
      - mynetwork

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "32788:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_PASSWORD: password1
    volumes:
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
      - ./wordpress:/var/www/html
    networks:
      - mynetwork

  php:
    image: php:8.0-fpm
    volumes:
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
    environment:
      PHP_MEMORY_LIMIT: 500M
    networks:
      - mynetwork

  ftp:
    image: stilliard/pure-ftpd:hardened
    environment:
      PUBLICHOST: "localhost"
      FTP_USER_NAME: "ftpuser"
      FTP_USER_PASS: "ftppassword"
      FTP_USER_HOME: "/var/www/html"
      FTP_PASSIVE_PORTS: "30000:30009"  # Указание диапазона пассивных портов
    volumes:
      - ./wordpress:/var/www/html
    ports:
      - "21:21"
      - "30000-30009:30000-30009"
    networks:
      - mynetwork

networks:
  mynetwork:

volumes:
  db_data:
  ftpdata:
Lariat answered 20/6 at 20:0 Comment(1)
Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient. Can you kindly edit your answer to offer an explanation?Georgeannageorgeanne
E
0

volumes: - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini

This doesn't work. It creates an empty folder "uploads.ini". (/data/compose/17/uploads.ini/) I create a file inside it (/data/compose/17/uploads.ini/uploads.ini) but nothing happens. It remains 2M file size limit.

Elamitic answered 2/7, 2022 at 8:22 Comment(2)
This is not an answer so it doesn't belong here. Instead you can add a comment or post a new question.Devol
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewStultify
A
-1

To increase upload limit you are to add these lines to docker-compose.yml file to wordpress environment section:

- PHP_POST_MAX_SIZE=150M

- PHP_UPLOAD_MAX_FILESIZE=150M

- PHP_MAX_EXECUTION_TIME=600

and exec commands:

> docker-compose down

> docker-compose up -d

Axiology answered 1/9, 2023 at 8:16 Comment(2)
Didn't work for me. Message "The uploaded file exceeds the upload_max_filesize directive in php.ini" is still present.Agitate
Where do you have these variables from? I don't see them in the documentation.Cruz
H
-2

The best answer is if you are just installing/uploading a compress file like xxx.zip file this error will pop up and you can not install it any plugin or theams so that you have to go to that file in the directory and open that xxx.zip file and delete unnecessary file for my case there is .git file which is 1.7 MB in size i delete it and it worked just fine. Hope this will solve your problem

Hyperphysical answered 24/11, 2022 at 13:32 Comment(2)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Smail
I did try this, but all "excess" I could find were locale files (responsible for translate to other languages), but still couldn't meet the 2MB quota. So seems that this does not apply to every caseAgitate

© 2022 - 2024 — McMap. All rights reserved.