Docker: PhpMyAdmin has an upload limit of 2048KiB
You've configured your Apache php.ini correctly with upload_max_filesize=50M and post_max_size=50M, yet when you access the PHPMyAdmin container at port 8080, it stubbornly enforces a 2MB (2048KiB) limit. This discrepancy happens because Dockerized applications do not share a single configuration space; they run as isolated processes with their own defaults unless explicitly overridden.
The root cause is the image you are using: phpmyadmin/phpmyadmin. Unless you have built a custom Dockerfile for it, this official image ships with its own default config.inc.php file located in /etc/phpmyadmin/config.user.inc.php (or similar paths depending on the specific version). This file hardcodes the maximum upload size to 2MB by default.
Where the configuration actually lives
In a traditional LAMP stack, you edit the global php.ini and Apache's .htaccess or virtual host config. In a containerized environment using pre-built images like phpmyadmin/phpmyadmin, the application logic often overrides system-wide PHP settings. The 2MB limit is not coming from your web server's php.ini; it is coming from the internal configuration of the PHPMyAdmin service itself.
To change this, you must inject a custom configuration file into the container that takes precedence over the default one. You can do this by mounting a volume or passing an environment variable.
Solution 1: Mounting a custom config file (Recommended)
The most robust way to override these settings is to mount a config.user.inc.php file from your host machine into the container's /etc/phpmyadmin/ directory. This ensures the configuration persists across container restarts and ignores the image defaults.
First, create a file on your host system (e.g., ./_docker/phpmyadmin/config.user.inc.php) with the following content:
<?php
/* vhost config */
$cfg['UploadDir'] = '/tmp';
$cfg['PmaAbsoluteUri'] = 'http://localhost:8080/';
// Set custom upload limits
$cfg['UploadMaxFilesize'] = 50 * 1024 * 1024; // 50MB in bytes
$cfg['TempDir'] = '/tmp';
$cfg['DumpBackupLimitMemory'] = true;
$cfg['Servers'][$i]['AllowRoot'] = false;
// Ensure the temp dir exists and is writable from within the container
?>
Then, update your docker-compose.yml to mount this file:
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- 8080:80
links:
- mysql
environment:
PMA_HOST: mysql
PMA_PORT: 3306
volumes:
- ./_docker/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php:ro
By mapping the file with :ro (read-only), you ensure the container uses your specific configuration while preventing accidental modification from within. This approach directly addresses the hardcoded limit by providing a higher-priority config file that the application loads upon startup.
Solution 2: Environment Variables
For newer versions of the PHPMyAdmin image, some settings can be overridden via environment variables. However, UploadMaxFilesize is less commonly exposed as a direct env var compared to other settings like PMA_HOST. If you find the file mounting method insufficient or the specific version supports it, check the documentation for supported environment variables such as PMA_UPLOAD_LIMIT.
Why your PHP info page showed 50M but PMA shows 2M
It is crucial to understand that phpinfo() displays the settings active for the current process. Since you verified these in your main webserver container, those settings are correct for that specific Apache instance. However, the phpmyadmin/phpmyadmin image runs a separate PHP-FPM or Apache process with its own compiled-in defaults and configuration files. The 2MB limit is essentially baked into the default installation of that specific image unless you explicitly mount a config file to override it.
Trade-offs and Considerations
Mounting a custom config file adds a slight complexity to your deployment pipeline; you must ensure the file is included in your build or volume sync before starting the container. If you are using a CI/CD pipeline, forget this step, and the upload limit will revert to 2MB immediately after redeploy.
Additionally, setting the upload directory to /tmp (as shown in the example) requires ensuring that the /tmp filesystem inside the container has sufficient space and permissions. In some restrictive environments, writing large temporary files to /tmp might fail if the underlying volume driver enforces strict size limits or if the process lacks write access.
If you require persistent uploads beyond a simple file upload form (e.g., handling large SQL dumps), verify that your phpmyadmin configuration also handles memory limits appropriately for the specific operation, as exceeding PHP's memory_limit can cause scripts to terminate even if upload_max_filesize is increased.
