Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Ubuntu docker with multiple mysql container

I hope you could help me.

I’m trying to setup a docker with multiple MySQL container in ubuntu server.

docker-compose.yml

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading