Hello. In this post, I will teach you how to deploy PHPMyAdmin using Docker compose. It will be brief but explained step by step.
I have to admit that these last days I have liked much more the technology of Docker compose. It seems a very simple and fast way to install certain applications. However, from my point of view, a bit of flexibility is lost in the configurations since they are images already created from a base. Of course, we will be able to configure some things but not everything.
Well, PHPMyAdmin is an application that is quite easy to install in Linux because it is available in most of the official refuels of the distributions. However, installing the latest version available from its source code may frighten some users. So this is a good way to install it.
Briefly
So, let us start.
Install Docker and Docker Compose on Linux
The first step is to have Docker installed in the system, obviously.
- If you are using Ubuntu: How to install Docker on Ubuntu 18.04?
- For CentOS 8: How to install Docker on CentOS 8?
- For CentOS 7: How to install Docker CE on CentOS 7?
- If you use Windows: How to install Docker in Windows 10?
- Or, if you are using Debian 10: How to install Docker on Debian 10?
And using your distribution’s package manager, you can install Docker Compose. For example:
:~$ sudo apt docker-compose
For Debian, Ubuntu and derivatives.
:~$ sudo yum install docker-compose
Or, for RHEL, CentOS and derivatives.
Install PHPMyAdmin using Docker Compose
The official PHPMyAdmin image requires the MySQL or MariaDB image to be installed. Anyway, in the docker-compose file, I will also add it in case you do not have it installed.
First, I will create a new folder and within it I will create the docker-compose.yml
file.
:~$ mkdir phpmyadmin :~$ cd phpmyadmin
Then, create the file and add the following:
:~$ nano docker-compose.yml
version: '2' volumes: db: services: db: image: mariadb command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW restart: always volumes: - db:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=1234osradar - MYSQL_PASSWORD=1234osradar - MYSQL_DATABASE=example - MYSQL_USER=osradar app: image: phpmyadmin/phpmyadmin container_name: phpmyadmin environment: - PMA_ARBITRARY=1 restart: always links: - db ports: - 8080:80 volumes: - /sessions
Save the changes and close the file.
The file itself is explicit but we are going to explain the most important parts. In the image we can see that we will try to raise two services: one is mariadb and the other PHPMyAdmin.
First we configure MariaDB that will work as the database manager. And we configured the environment variables that will allow us to define the password of the root user, the normal user and the user name.
In the case of PHPMyAdmin is even simpler because by default only requires that we specify within the environment if it is an arbitrary host. Then, we define the port where we will have access, in this case, I left the 8080. All better explained in the official documentation of the PHPMyAdmin image.
Finally, run docker compose to install PHPMyAdmin.
:~$ sudo docker-compose up -d
Then, we will be able to access from our browser using the IP address of the server or the domain name with port 8080 that we specify. Then, log in with your credentials:
Finally you will see the main screen.
So, that is it.
Conclusion
In a production server, we look very much for the productivity and compatibility of the applications. In this sense, using Docker images guarantees compatibility and ease of use. Today, you have learned how to install PHPMyAdmin using this technology and we will be able to realize how simple it is.
Approved by a phpMyAdmin team member !
Nice tutorial 🙂
Oh, Thanks!!!
This is what I get when trying to run `docker-compose up -d`:
ERROR: yaml.parser.ParserError: while parsing a block mapping
in “.\docker-compose.yml”, line 1, column 1
expected , but found ”
in “.\docker-compose.yml”, line 3, column 5