Public | Automated Build

Last pushed: 8 days ago
Short Description
phpMyAdmin as Docker container, based on official PHP image, always latest version
Full Description

phpMyAdmin as Docker container

This container may be used with MySQL or MariaDB linked containers.

If you like this image - you may also like set of images for WebServer.

#How to use
With MySQL:

docker run --name mysql -e MYSQL_ROOT_PASSWORD=my_password -d mysql
docker run --rm --link mysql:mysql -p 1234:80 nazarpc/phpmyadmin

With MariaDB:

docker run --name mariadb -e MYSQL_ROOT_PASSWORD=my_password -d mariadb
docker run --rm --link mariadb:mysql -p 1234:80 nazarpc/phpmyadmin

(internally it should be called mysql anyway)

After these commands you'll be able to access phpMyAdmin via http://localhost:1234, press Ctrl+C to stop container, and it will be removed automatically (because of --rm option). Feel free to change 1234 to any port you like.

Specify allowed upload file size

Sometimes it is necessary to upload big dump which doesn't fit into default limit 128M. You can specify alternative size via environment variable UPLOAD_SIZE:

docker run --rm --link mysql:mysql -p 1234:80 -e UPLOAD_SIZE=1G nazarpc/phpmyadmin

Increase session timeout

The default session timeout is just 1440 seconds (24 minutes). You can specify an alternative timeout by setting the environment variable SESSION_TIMEOUT:

docker run --rm --link mysql:mysql -p 1234:80 -e SESSION_TIMEOUT=86400 nazarpc/phpmyadmin

Customize host name

By default phpMyAdmin assumes MySQL is available through mysql hostname. Sometimes this is not the case, so you can override this with environmental variable MYSQL_HOST:

docker run --rm --link mysql:mysql -p 1234:80 -e MYSQL_HOST=mariadb:9999 nazarpc/phpmyadmin

Examples of valid MYSQL_HOST:

  • mariadb - hostname mariadb
  • mariadb:9999 - hostname mariadb with port 9999
  • mariadb;root - hostname mariadb with user root
  • mariadb;root;123 - hostname mariadb with user root & password 123
  • mariadb:9999;root;123 - hostname mariadb with user root, password 123 & port 9999
  • mysql, mariadb:9999, mariadb:9999;root;123 - multiple servers

Allow connecting to arbitrary MySQL host

docker run --rm --link mysql:mysql -p 1234:80 -e ALLOW_ARBITRARY=1 nazarpc/phpmyadmin

Custom URI of phpMyAdmin instance

Sometimes phpMyAdmin may determine its own URI incorrectly. Usually you can fix it by correcting virtual host of revers proxy, but sometimes it might be useful to specify URI explicitly:

docker run --rm --link mysql:mysql -p 1234:80 -e ABSOLUTE_URI=https://domain.tld/phpmyadmin nazarpc/phpmyadmin

Custom phpMyAdmin settings

You can specify any PMA-config-setting using a JSON object passed to JSON_CONFIG, that will be merged to the existing config.

docker run --rm --link mysql:mysql -p 1234:80 -e JSON_CONFIG='{"AllowUserDropDatabase": true,"MaxTableList": 450, "NavigationTreeTableSeparator": "_"}' nazarpc/phpmyadmin

Difference from other similar images with phpMyAdmin

This image doesn't use any custom base, just official PHP 5.6 container with built-in Apache2 web server.
There is support for importing SQL dumps in all compression formats supported by phpMyAdmin.
There is possibility to connect to multiple servers of your choice or even to arbitrary servers if necessary.

Also this image generates blowfish_secret configuration option (unique for each container instance, you don't have to rebuild it yourself) on each container start, so that you will automatically use cookie sessions (for your convenience).

Plus, I'll try to keep it up to date with new releases of phpMyAdmin (as well as PHP itself and other software inside image), so, by using nazarpc/phpmyadmin image you'll always have latest versions.

Open an issue and ask your question there:)

Public Domain

Docker Pull Command
Source Repository

Comments (13)
8 months ago

how to use another port for Mysql please?
thanks a lot

a year ago

@nazarpc thank you for this excellent container. As a beginner it took me a while to figure out how to get this to work with my existing docker-compose setup.

Sharing what I have

version: '2'
build: nginx

      - "8080:80"
      - ./src/public:/usr/share/nginx/html:ro

      - ./src/nginx/sites-enabled:/etc/nginx/sites-enabled
      - ./src/nginx/snippets:/etc/nginx/snippets
      - ./src/nginx/nginx.conf:/etc/nginx/nginx.conf

      - php

    build: php

      nproc: 65535
        soft: 20000
        hard: 40000

    mem_limit: 4000000000
    memswap_limit: 8000000000
privileged: true

  - ./src/public:/usr/share/nginx/html
  # On the php service run ps aux | grep php-fpm to see where the php-fpm.conf is found
  #decided to stop sharing these files and use the Dockerfile to create the required entries
  #- ./php/conf:/usr/local/etc
  - ./files:/files
  - db

build: mysql

 - ./mysql/db:/var/lib/mysql
 - ./mysql/source:/home/mysql
 - ./mysql/source:/docker-entrypoint-initdb.d

    # Environment should be set in docker-compose.override.yml
      - MYSQL_DATABASE=model
      - MYSQL_USER=root
      - DB_NAME=model
      - DB_USER=root
      - DB_PASS=

# Add a phpmyadmin container when needed.
# to launch
# credentials: root / blank 

    image: nazarpc/phpmyadmin
    - "8000:80"
    - db:mysql

Put simply, a new service phpmyadmin is added and when using docker-compose v2 files, the link -db:mysql is used to connect phpmyadmin to my database.


2 years ago

Great work nazarpc ! works like a charm :)

I have a little problem here as I put an haproxy which handle ssl on top of my frontoffice and your phpmyadmin container.

I got the login page perfectly in ssl, but once credentials are filled in, it redirects to https://<host>:80/index...

If I get rid of the ":80" in the urlbar manually then everything works fine, I can navigate in phpmyadmin.

Would you consider enabling 'PmaAbsoluteUri' modification through an environment variable ? (I use envplate to do so in some other images I got)

Cheers !

2 years ago

@gadieichhorn, generally you'll need to create separate PhpMyAdmin instance for each DB instance, there is no possibility to use it with multiple hosts out of the box, but I'll think about how to add it.

2 years ago

Great idea to have this stand alone admin console without the underlying DB.
I have 4 mysql instances in my setup (docker-compose) and I would like to manage them all from one place.
How do you suggest I will do that?

image: nazarpc/phpmyadmin

- "80:80"


- config
- main
- empty
- archive


2 years ago

@gonberdeal, I've just pushed an updated config file, case when hostname of mysql container is mysql now handled out of the box even within custom networks.

2 years ago

When using a user-defined network from docker-engine 1.9 instead of links; you have to use environment variable MYSQL_PORT_3306_TCP_ADDR to set the hostname of the mysql server.

MySQL example:

docker network create my-network
docker run --name mysql --net=my-network -e MYSQL_ROOT_PASSWORD=my_password -d mysql
docker run --rm --net=my-network -e MYSQL_PORT_3306_TCP_ADDR=mysql -p 1234:80 nazarpc/phpmyadmin
2 years ago

@gcis, What names do you mean? You just link it to existing MySQL/MariaDB container and enter user credentials in Web UI.

2 years ago

it doesn't work for me.. no way to connect to my DB. tried different names, mariaDB/mysql... bit it's not connecting

2 years ago

@stilet69 there is no password and username, it depends on container you're linking it to.