Docker Recipe: Running MySQL and PHPMyAdmin
In the following Docker-Compose Snippet you can install and run MySQL, and PHPMyAdmin in few mins. Just make sure to have Docker and Docker-compose installed.
Create a folder for your project, then paste this in docker-compose.yml
file:
version: "3.7"
services:
web:
image: nginx:1.17
ports:
- 80:80
volumes:
- /var/www/docker-study.loc/recipe-03/php:/var/www/myapp
- /var/www/docker-study.loc/recipe-03/docker/site.conf:/etc/nginx/conf.d/site.conf
depends_on:
- php
- mariadb
php:
image: php:7.2-fpm
volumes:
- /var/www/docker-study.loc/recipe-03/php:/var/www/myapp
- /var/www/docker-study.loc/recipe-03/docker/php.ini:/usr/local/etc/php/php.ini
depends_on:
- mariadb
mariadb:
image: mariadb:10.4
restart: always
ports:
- 3306:3306
volumes:
- mariadb-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: YOURMYSQLPASSWORD
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
ports:
- 8000:80
environment:
- PMA_ARBITRARY=1
- PMA_HOST=mariadb
depends_on:
- mariadb
volumes:
mariadb-data:
Then run your Docker using Docker-compose:
docker-compose up -d
After downloading and running the images you can access your PHPMyAdmin on this link:
http://localhost:8000/