Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Dockerized phpMyAdmin Cheatsheet

Examples

Standalone Deployment

If you just want to deploy a phpmyadmin instance, that you then use to connect to any number of other hosts on the internet, then you could do this:

services:

    phpmyadmin:
        image: phpmyadmin:5.2-apache
        container_name: phpmyadmin
        restart: unless-stopped
        ports:
            - "80:80"

However, this is generally not very useful, and your starting point is probably going to be the internally connected setup outlined below.

Internally Networked Setup

This is a minimal example setup (you probably want to add logging clauses etc), in which I am running phpMyAdmin to access a database on the same host through the internal networking, allowing me to not have the database port exposed to the internet. I am also accessing phpmyadmin on a custom port of 8080, because my web app is using port 80.

services:

    phpmyadmin:
        image: phpmyadmin:5.2-apache
        container_name: phpmyadmin
        restart: unless-stopped
        depends_on:
            - db
        ports:
            - "8080:80"


    # A database to be accessed/managed through phpMyAdmin
    db:
        image: mariadb:11.6-noble
        container_name: db
        restart: always
        volumes:
            - db-data:/var/lib/mysql

        # Uncomment this ports section if wish for database to be 
        # accessible from the outside world, but you probably don't
        # need to if  you can already access it through phpMyAdmin
        #ports:
        #    - 3306:3306

        environment:
            - MYSQL_DATABASE=${DB_NAME}
            - MYSQL_USER=${DB_USER}
            - MYSQL_PASSWORD=${DB_USER_PASSWORD}
            - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}


    # A representation of your custom application
    # that uses your MariaDB database
    app:
        container_name: app
        image: myCustomWebApp
        restart: unless-stopped
        ports:
            - "80:80"
        depends_on:
            - db

volumes:
    db-data:
        driver: local

This version does not use SSL/TLS for phpMyAdmin so you should only connect to phpMyAdmin if you have some other means of enforcing an encrypted connection to the host such as a reverse proxy, or a VPN to inside an internal NAT that you connect internally to the host from (e.g. not then over the internet from the VPN). Alternatively, look at my option for adding SSL/TLS to phpMyAdmin.

No Login Required

You can automatically provide phpMyAdmin the username and password to use so that there is no login required.

This should likely only be done if one can use an external firewall service (such as through Proxmox, or AWS security groups), to restrict the phpMyAdmin port to only be accessible on IPs you trust. Doing this through iptables or UFW with Docker is not going to work, unless you know know about the implications of Docker and iptables.

services:

    phpmyadmin:
        image: phpmyadmin:5.2-apache
        container_name: phpmyadmin
        restart: always
        ports:
            - "8080:80"
        environment:
            - PMA_HOST=${DB_HOST}
            - PMA_USER=root
            - PMA_PASSWORD=${DB_ROOT_PASSWORD}

SSL/TLS Support

Unfortunately, the official Docker image for phpMyAdmin does not have native support for adding TLS certificates. However, it is super easy to build your own custom image to add this yourself, or you can just use my pre-built image (programster/phpmyadmin) using the same code.

Since the image is built using the official image as a base image, all of the customizations performed through environment variables still work.

Increased Max Upload Size

If you need to import a larger than tiny database into phpMyAdmin, then you will need to customize the max upload size by providing the UPLOAD_LIMIT environment variable like below:

    phpmyadmin:
        image: phpmyadmin:5.2-apache
        container_name: phpmyadmin
        environment:
            - UPLOAD_LIMIT=1024000k
Last updated: 16th January 2026
First published: 16th January 2026

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch