3 C
Texas
angeloma
Senior Writer and partner

Deploy PHPMyAdmin using Docker Compose

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, I will tell you that Docker compose is more thought of production environments where compatibility should be as high as possible. This is precisely the great advantage of Docker images that we will be able to use in any supported system thanks to the technology of containers. Then, these steps can be done from any Linux distribution that has installed Docker and Docker Compose.

- Advertisement -

So, let us start.

Install Docker and Docker Compose on Linux

The first step is to have Docker installed in the system, obviously.

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
1.- Creating a folder
1.- Creating a folder

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
2.- The Docker-compose file for PHPMyAdmin
2.- The Docker-compose file for PHPMyAdmin

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
3.- Installing PHPMyAdmin using Docker compose
3.- Installing PHPMyAdmin using Docker compose

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:

4.- PHPMyAdmin using Docker Compose
4.- PHPMyAdmin using Docker Compose

Finally you will see the main screen.

5.- PHPMyAdmin Running
5.- PHPMyAdmin Running

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.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

3 COMMENTS

  1. 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

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article