通过安装两个不同版本的MySQL数据库以及PostgreSQL数据库,然后通过adminer
web界面进行管理。
整个项目的目录结构如下:
├── data # MySQL数据目录
├── docker-compose.yml
└── my.conf # MySQL配置文件
docker-compose.yaml文件:
version: '3'
services:
mysql-dev:
image: hub.docker-registry.com/library/mysql:8.0.2
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: blogapp
ports:
- "3308:3306"
volumes:
- "./data:/var/lib/mysql:rw"
- "./my.conf:/etc/mysql/conf.d/config-file.cnf"
mysql-legacy:
image: hub.docker-registry.com/library/mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: blogapp
ports:
- "3309:3306"
admin:
image: hub.docker-registry.com/library/adminer
ports:
- 8080:8080
pgdb:
image: hub.docker-registry.com/library/postgres:9.6.15-alpine
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: password
POSTGRES_DB: blogapp
my.conf文件
[mysqld]
bind-address = 0.0.0.0
max_connections = 505
max_user_connections = 500
这里需要注意的是:服务器填的是yaml文件中的服务名称
网友评论