Install phpMyAdmin Inside Docker Container in Linux

Install phpMyAdmin Inside Docker Container in Linux

The phpMyAdmin is an open-source administration tool that allows to manage MySQL and MariaDB database servers through a web browser.

This tutorial explains how to install phpMyAdmin inside a Docker container in the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

You also need to have a running MySQL container. Instructions can be found in the post.

Install phpMyAdmin

  • Host network

Run the following command to create a container for phpMyAdmin that uses host network:

docker run -d --name=phpmyadmin --restart=always --network=host \
    -e PMA_HOST=127.0.0.1 \
    phpmyadmin

MySQL container should run on host network as well.

  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, phpMyAdmin service is listening on port 80. It can be changed with -p option.

docker network create app-net
docker run -d --name=phpmyadmin --restart=always --network=app-net \
    -p 8080:80 \
    -e PMA_HOST=mysql \
    phpmyadmin

MySQL container should run on the same user-defined bridge network as well.

Note: When user-defined bridge network is used, don't forget to change PMA_HOST. It specifies MySQL container name.

Testing phpMyAdmin

Open a web browser and go to http://<IP_ADDRESS>, where <IP_ADDRESS> is the IP address of the system. Provide username and password to log in to database server.

Install phpMyAdmin Inside Docker Container in Linux

Uninstall phpMyAdmin

To completely remove phpMyAdmin, remove its container:

docker rm --force phpmyadmin

Remove phpMyAdmin image:

docker rmi phpmyadmin

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.