Wordpress Docker won't increase upload limit

Kyle Calica-St picture Kyle Calica-St · Mar 23, 2017 · Viewed 18.8k times · Source

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'

Answer

smaqsood picture smaqsood · Jan 2, 2019

it worked for me as follows: i created uploads.ini in my local directory (where .yml file is) 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?...