Installing using Docker

phpMyAdmin comes with a Docker image, which you can easily deploy. You can download it using:

docker pull phpmyadmin/phpmyadmin 

The phpMyAdmin server will listen on port 80. It supports several ways of configuring the link to the database server, either by Docker's link feature by linking your database container to db for phpMyAdmin (by specifying --link your_db_host:db) or by environment variables (in this case it's up to you to set up networking in Docker to allow the phpMyAdmin container to access the database container over the network).

Docker environment variables

You can configure several phpMyAdmin features using environment variables:

PMA_ARBITRARY

Allows you to enter a database server hostname on login form.

PMA_HOST

Hostname or IP address of the database server to use.

PMA_HOSTS

Comma-separated hostnames or IP addresses of the database servers to use.

Note

Used only if PMA_HOST is empty.

PMA_VERBOSE

Verbose name of the database server.

PMA_VERBOSES

Comma-separated verbose name of the database servers.

Note

Used only if PMA_VERBOSE is empty.

PMA_USER

User name to use for Config authentication mode.

PMA_PASSWORD

Password to use for Config authentication mode.

PMA_PORT

Port of the database server to use.

PMA_PORTS

Comma-separated ports of the database server to use.

Note

Used only if PMA_PORT is empty.

PMA_ABSOLUTE_URI

The fully-qualified path (https://pma.example.net/) where the reverse proxy makes phpMyAdmin available.

By default, Cookie authentication mode is used, but if PMA_USER and PMA_PASSWORD are set, it is switched to Config authentication mode.

Note

The credentials you need to log in are stored in the MySQL server, in case of Docker image, there are various ways to set it (for example MYSQL_ROOT_PASSWORD when starting the MySQL container). Please check documentation for MariaDB container or MySQL container.

Customizing configuration

Additionally configuration can be tweaked by /etc/phpmyadmin/config.user.inc.php. If this file exists, it will be loaded after configuration is generated from above environment variables, so you can override any configuration variable. This configuration can be added as a volume when invoking docker using -v /some/local/directory/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php parameters.

Note that the supplied configuration file is applied after Docker environment variables, but you can override any of the values.

For example to change the default behavior of CSV export you can use the following configuration file:

<?php $cfg['Export']['csv_columns'] = true; 

You can also use it to define server configuration instead of using the environment variables listed in Docker environment variables:

<?php /* Override Servers array */ $cfg['Servers'] = [     1 => [         'auth_type' => 'cookie',         'host' => 'mydb1',         'port' => 3306,         'verbose' => 'Verbose name 1',     ],     2 => [         'auth_type' => 'cookie',         'host' => 'mydb2',         'port' => 3306,         'verbose' => 'Verbose name 2',     ], ]; 

See also

See Configuration for detailed description of configuration options.

Docker Volumes

You can use the following volumes to customize image behavior:

/etc/phpmyadmin/config.user.inc.php

Can be used for additional settings, see the previous chapter for more details.

/sessions/

Directory where PHP sessions are stored. You might want to share this for example when using Signon authentication mode.

/www/themes/

Directory where phpMyAdmin looks for themes. By default only those shipped with phpMyAdmin are included, but you can include additional phpMyAdmin themes (see Custom Themes) by using Docker volumes.

Docker Examples

To connect phpMyAdmin to a given server use:

docker run --name myadmin -d -e PMA_HOST=dbhost -p 8080:80 phpmyadmin/phpmyadmin 

To connect phpMyAdmin to more servers use:

docker run --name myadmin -d -e PMA_HOSTS=dbhost1,dbhost2,dbhost3 -p 8080:80 phpmyadmin/phpmyadmin 

To use arbitrary server option:

docker run --name myadmin -d --link mysql_db_server:db -p 8080:80 -e PMA_ARBITRARY=1 phpmyadmin/phpmyadmin 

You can also link the database container using Docker:

docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 phpmyadmin/phpmyadmin 

Running with additional configuration:

docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 -v /some/local/directory/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php phpmyadmin/phpmyadmin 

Running with additional themes:

docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 -v /custom/phpmyadmin/theme/:/www/themes/theme/ phpmyadmin/phpmyadmin 

Using docker-compose

Alternatively, you can also use docker-compose with the docker-compose.yml from <https://github.com/phpmyadmin/docker>. This will run phpMyAdmin with an arbitrary server - allowing you to specify MySQL/MariaDB server on the login page.

docker-compose up -d 

Customizing configuration file using docker-compose

You can use an external file to customize phpMyAdmin configuration and pass it using the volumes directive:

phpmyadmin:     image: phpmyadmin/phpmyadmin     container_name: phpmyadmin     environment:      - PMA_ARBITRARY=1     restart: always     ports:      - 8080:80     volumes:      - /sessions      - ~/docker/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php      - /custom/phpmyadmin/theme/:/www/themes/theme/ 

Running behind haproxy in a subdirectory

When you want to expose phpMyAdmin running in a Docker container in a subdirectory, you need to rewrite the request path in the server proxying the requests.

For example, using haproxy it can be done as:

frontend http     bind *:80     option forwardfor     option http-server-close      ### NETWORK restriction     acl LOCALNET  src 10.0.0.0/8 192.168.0.0/16 172.16.0.0/12      # /phpmyadmin     acl phpmyadmin  path_dir /phpmyadmin     use_backend phpmyadmin if phpmyadmin LOCALNET  backend phpmyadmin     mode http      reqirep  ^(GET|POST|HEAD)\ /phpmyadmin/(.*)     \1\ /\2      # phpMyAdmin container IP     server localhost     172.30.21.21:80 

When using traefik, something like following should work:

defaultEntryPoints = ["http"] [entryPoints]   [entryPoints.http]   address = ":80"     [entryPoints.http.redirect]       regex = "(http:\\/\\/[^\\/]+\\/([^\\?\\.]+)[^\\/])$"       replacement = "$1/"  [backends]   [backends.myadmin]     [backends.myadmin.servers.myadmin]     url="http://internal.address.to.pma"  [frontends]    [frontends.myadmin]    backend = "myadmin"    passHostHeader = true      [frontends.myadmin.routes.default]      rule="PathPrefixStrip:/phpmyadmin/;AddPrefix:/" 

You then should specify PMA_ABSOLUTE_URI in the docker-compose configuration:

version: '2'  services:   phpmyadmin:     restart: always     image: phpmyadmin/phpmyadmin     container_name: phpmyadmin     hostname: phpmyadmin     domainname: example.com     ports:       - 8000:80     environment:       - PMA_HOSTS=172.26.36.7,172.26.36.8,172.26.36.9,172.26.36.10       - PMA_VERBOSES=production-db1,production-db2,dev-db1,dev-db2       - PMA_USER=root       - PMA_PASSWORD=       - PMA_ABSOLUTE_URI=http://example.com/phpmyadmin/