Using MariaDB and phpMyAdmin with Docker and Docker Compose

Andrés

7 July 2023

Using MariaDB and phpMyAdmin with Docker and Docker Compose Quickly and efficiently configure MariaDB and phpMyAdmin in Docker Compose to simplify the management of your databases in your development environment.

MariaDB is one of the most popular open source relational database management systems in the world, and on the other hand, PhpMyadmin is another great stable and also free software tool written in PHP that serves to manage both databases on a MySQL server and MariaDB.

And docker will be the tool that will help us to run these two services in an easy and fast way, with data persistence. So we will have an environment ready in a few minutes to continue working.

Docker compose up: MariaDB and PhpMyAdmin

Installation of Docker is required. If you haven’t done so already, please follow the official guides provided here.

Create a folder in your project directory and inside it a docker-compose.yml file with the following content:

version: "3.8"

services:
  mysql:
    image: mariadb:latest
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: rootpass
      MYSQL_USER: abc
      MYSQL_PASSWORD: abc123
    volumes:
      - mysql:/var/lib/mysql
    restart: unless-stopped

  phpmyadmin:
    image: phpmyadmin:latest
    ports:
      - 8080:80
    environment:
      PMA_HOST: mysql
      PMA_USER: auser
      PMA_PASSWORD: pass12345
    restart: unless-stopped

volumes:
  mysql:

  • Link to the complete documentation of the image used for MariaDB.
  • Linkto the full documentation of the image used for PhpMyadmin.

Save the changes and then raise the containers with the following command:

docker compose up

If you want to leave the containers running in background don’t forget the -d flag. You will be able to access PhpMyadmin in your browser at http://localhost:8080.

And that’s it. Important: You can use whatever credentials you want as long as it is a local development environment and do not pretend to use this docker compose definition in a productive environment.

¡Hola a todos! 👋 ¿Disfrutaron leyendo el artículo? ¡Me encantaría conocer sus opiniones! 💬 No duden en dejar un comentario abajo, ya sea para compartir sus comentarios, preguntas o simplemente saludar. ¡No es necesario registrarse, solo compartan algo valioso! 😊
Hey there! 👋 Enjoyed reading the post? I'd love to hear your thoughts! 💬 Feel free to drop a comment below—whether it's feedback, questions, or just saying hi. No need to sign up, just share something valuable! 😊
Carbon impact of this web page
👷 Contratame / Hire me 👷