I hope you could help me.
I'm trying to setup a docker with multiple MySQL container in ubuntu server.
docker-compose.yml
version: '3.1'
services:
mysql-db_1:
image: mysql:8.0.28-debian
command: --sql_mode="" --default-authentication-plugin=mysql_native_password
restart: always
ports:
- '3306:3306'
volumes:
- ./data_1/files:/var/lib/mysql-files
- ./data_1/data:/var/lib/mysql
mysql-db_2:
image: mysql
command: --sql_mode="" --default-authentication-plugin=mysql_native_password
restart: always
ports:
- '3307:3307'
volumes:
- ./data_2/files:/var/lib/mysql-files
- ./data_2/data:/var/lib/mysql
Everything is successfully built and I was able to connect to port 3306 however I can't connect to port 3307.
CodePudding user response:
Your mysql-db_2
container port is invalid.
you can change it to 3307:3306
so it will be exposed at port 3307, but the container itself will be listening on port 3306
mysql-db_2:
image: mysql
command: --sql_mode="" --default-authentication-plugin=mysql_native_password
restart: always
ports:
- '3307:3306'
volumes:
- ./data_2/files:/var/lib/mysql-files
- ./data_2/data:/var/lib/mysql