Skip to content

Instantly share code, notes, and snippets.

@h1ddengames
Created February 20, 2021 06:02
Show Gist options
  • Save h1ddengames/5ea074e2aa673b02f43f5b0f05215966 to your computer and use it in GitHub Desktop.
Save h1ddengames/5ea074e2aa673b02f43f5b0f05215966 to your computer and use it in GitHub Desktop.
MySQL Database + PhpMyAdmin using env file Docker-Compose
MYSQL_ROOT_PASSWORD=
MYSQL_USER=
MYSQL_PASSWORD=
MYSQL_DATABASE=
version: '3.9'
# Usage:
## Start up all services:
### docker-compose -f docker/docker-compose.yml up -d
## -f flag to specify the filename if filename is not docker-compose.yml or if it's not located in the current directory.
## -d flag is used to detach the container's output from the terminal so you can keep using the same terminal.
## Shutdown all services:
### docker-compose -f docker/docker-compose.yml down
## -f flag to specify the filename if filename is not docker-compose.yml or if it's not located in the current directory.
services:
# BACKUP MYSQL by generating dump file
# docker exec CONTAINER-NAME mysqldump -u root --password=root DATABASE-NAME > backup.sql
# RESTORE MYSQL from dump file
# docker exec -i CONTAINER-NAME mysql -u root --password=root DATABASE-NAME < backup.sql
db-node:
container_name: db-node
image: mysql:5.7
restart: always
command:
--default-authentication-plugin=mysql_native_password
env_file:
- database.env
ports:
- target: 3306
published: 3306
protocol: tcp
mode: host
phpmyadmin-node:
depends_on:
- db-node
container_name: phpmyadmin-node
image: phpmyadmin/phpmyadmin:5.0.0
restart: always
env_file:
- database.env
- phpmyadmin.env
ports:
- target: 80
published: 8080
protocol: tcp
mode: host
# adminer-node:
# container_name: adminer-node
# image: adminer
# restart: always
# ports:
# - target: 8080
# published: 8080
# protocol: tcp
# mode: host
# MYSQL ENVIRONMENT
# environment:
# MYSQL_ROOT_PASSWORD:
# MYSQL_USER:
# MYSQL_PASSWORD:
# MYSQL_DATABASE:
# PHPMYADMIN ENVIRONMENT
# environment:
# PMA_HOST:
# PMA_PORT:
# MYSQL_ROOT_PASSWORD:
PMA_HOST=
PMA_PORT=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment