1. Install Docker & Docker Compose
You can refer to how to install Docker & Docker Compose in How to Containerize a React Application Using Docker
2. Prepare docker-compose.yml file
# docker-compose.yml version: "3" services: database: image: mysql command: --default-authentication-plugin=mysql_native_password ports: - "3306:3306" # Configure port for MySQL environment: - MYSQL_ROOT_PASSWORD=123456 # Your root password - TZ=Asia/Ho_Chi_Minh volumes: - mysqldb:/var/lib/mysql restart: always phpmyadmin: image: phpmyadmin/phpmyadmin environment: - PMA_ARBITRARY=10 - PMA_HOST=database - PMA_PORT=3306 - UPLOAD_LIMIT=100000000 restart: always ports: - "8080:80" # Configure port for phpMyAdmin links: - database volumes: mysqldb:
3. Run Container
Open your terminal and run the following command:
docker-compose up -d --build
Once it's done, MySQL will be running on port:3306
and phpMyAdmin will be accessible on port:8080
. You can try accessing phpMyAdmin at http://localhost:8080
4. Conclusion
Deploying MySQL and phpMyAdmin with Docker simplifies deployment, ensures consistent environments, and optimizes resource usage. More deployment methods will be covered in future articles.