I have a MySQL container running (version 8, but tried with 5.x) where I can access the port 3307 from an external Java program (not in docker). That’s OK for a test to make sure the database is accessible in at least one case, but I need it to accessible from another docker container.
However, for whatever reason, need help with this, I cannot get my service running in one docker container to talk to the MySQL container running in docker.
My ports configuration for MySQL in docker-compose.yml is simply:
ports:
- 3307:3306
–
When docker loads MySQL via the docker-compose file, the last line says:
“[System] [MY-011323] [Server] X Plugin ready for connections. Socket: ‘/var/run/mysqld/mysqlx.sock’ bind-address: ‘::’ port: 33060”
the line above that, says:
“[Server] /usr/sbin/mysqld: ready for connections. Version: ‘8.0.13’ socket: ‘/var/run/mysqld/mysqld.sock’ port: 3306 MySQL Community Server - GPL.”
Yet, regardless of what ports I use in the JDBC connection string, I get:
“Could not create connection to database server. Attempted reconnect 3 times. Giving up.”
I’ve tried:
“jdbc:mysql://0.0.0.0:33060/ZipCodeLookup?useSSL=false&” + “serverTimezone=America/New_York&user=root&password=thepass&autoReconnect=true”;
“jdbc:mysql://192.168.0.1:33060/ZipCodeLookup?useSSL=false&” + “serverTimezone=America/New_York&user=root&password=thepass&autoReconnect=true”;
“jdbc:mysql://localhost:33060/ZipCodeLookup?useSSL=false&” + “serverTimezone=America/New_York&user=root&password=thepass&autoReconnect=true”;
“jdbc:mysql://localhost:3307/ZipCodeLookup?useSSL=false&” + “serverTimezone=America/New_York&user=root&password=thepass&autoReconnect=true”;
“jdbc:mysql://localhost:3306/ZipCodeLookup?useSSL=false&” + “serverTimezone=America/New_York&user=root&password=thepass&autoReconnect=true”;
and other combinations.
I appear to be confused what the “bind address” is and how to properly use it. I’ve searched on Stackoverflow, but the examples there are confusing.
Would appreciate advice on how to configure mysql access from another container.
Thanks very much.
- mike