Docker-compose is an useful utility for managing multi-container docker applications. In our previous tutorial, I had discussed about the keep persistent data of MySQL docker containers using Docker volumes. Once you launched a MySQL container can be connect via terminal directly. But the phpMyAdmin lovers may need the web interface for managing databases.
In this tutorial, you will learn to launch MySQL Docker containers along with phpMyAdmin docker container using docker-compose command.
This guide assumes that you have already done the followings:
- You have installed Docker service on your System
- Also, have configured docker-compose utility on your system
How to Create MySQL with phpMyAdmin Docker Container
phpMyAdmin is an most popular web application for managing MySQL database servers. In this tutorial, we just use an example of Docker container for MySQL and phpMyAdmin.
So first create a docker-compose.yml file on your system with the following content.
Save you file and close it.
Next, run the following command to create Docker containers using the docker-compose.yml configuration file.
docker-compose up -d
The above command will launch two Docker containers, one for MySQL database server and one for phpMyAdmin. Also a data volume will be created, which is attached with MySQL container to make data persistent.
Now, access the phpMyAdmin using the web browser. I am running this example on my local machine. So used host as localhost with port 8081 defined in docker compose configuration. You need to change localhost with your server ip address to access it remotely.
In this tutorial, you have learned to launch a MySQL docker container with a phpMyAdmin. Which help help you to manage databases on MySQL docker container.
how make like localhost/phpmyadmin to display phpmyadim
Hi Rahul, thanks for this… I am wondering how you create the MySQL connection URL from the environment variables you have listed from lines 7-13 in the docker-compose.yml file? does port take the place of in the connection URL?
Here port is used to bind host machine port (6033) to bind mysql port (3306) running in container.
If you are connecting docker container from another docker container, no need to define port. It will connect over default port.
But when connecting mysql from host machine use 6033 port to connect mysql running under container.