Traffic between phpMyAdmin and a remote database can cross networks where credentials and query results should not travel in clear text. TLS encrypts that connection, while certificate verification prevents phpMyAdmin from accepting an impostor that presents an untrusted certificate.
The official phpMyAdmin container loads /etc/phpmyadmin/config.user.inc.php after its generated server configuration. Keeping the override and CA certificate under ./phpmyadmin/ beside compose.yaml gives Docker Compose explicit host files to mount read-only at the paths used by the web process.
The database server must already offer TLS with a certificate whose subject alternative name matches its DNS host name. The ssl, ssl_ca, and ssl_verify settings enable encryption and verify the server identity; client certificate settings such as ssl_cert and ssl_key are needed only when the database account requires mutual TLS.
$ install -d -m 0755 phpmyadmin
$ install -m 0644 database-ca.pem phpmyadmin/database-ca.pem
The CA certificate is public trust material, not the database server's private key. Database private keys do not belong in the phpMyAdmin project unless mutual TLS is required.
$ vi phpmyadmin/config.user.inc.php
<?php $cfg['Servers'][1]['host'] = 'database.example.net'; $cfg['Servers'][1]['ssl'] = true; $cfg['Servers'][1]['ssl_ca'] = '/etc/phpmyadmin/database-ca.pem'; $cfg['Servers'][1]['ssl_verify'] = true;
Setting ssl_verify to false disables certificate and host-name verification, allowing a man-in-the-middle server to impersonate the database endpoint.
services: phpmyadmin: volumes: - ./phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php:ro - ./phpmyadmin/database-ca.pem:/etc/phpmyadmin/database-ca.pem:ro
$ docker compose config --quiet
$ docker compose up --detach --force-recreate phpmyadmin
$ docker compose exec phpmyadmin ls -l /etc/phpmyadmin/config.user.inc.php /etc/phpmyadmin/database-ca.pem
$ docker compose exec phpmyadmin php -l /etc/phpmyadmin/config.user.inc.php No syntax errors detected in /etc/phpmyadmin/config.user.inc.php
