New to docker, help with docker hive container mysql driver issue

https://hub.docker.com/r/apache/hive

I did try HIVE_VERSION=3.1.3
and also tried 4.0.0-alpha-2

  • 4.0.0-alpha-2
  • 4.0.0-alpha-1

I want to use this one ( This section is in readme document )

Launch Standalone Metastore With External RDBMS (Postgres/Oracle/MySql/MsSql)

I want to use MySQL as remote database

I tried com.mysql.jdbc.Driver and com.mysql.cj.jdbc.Driver

docker run -it -d -p 9083:9083 --env SERVICE_NAME=metastore --add-host=host.docker.internal:host-gateway \
     --env DB_DRIVER=mysql \
     --env SERVICE_OPTS="-Djavax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver -Djavax.jdo.option.ConnectionURL=jdbc:mysql://host.docker.internal:3306/hive?createDatabaseIfNotExist=true -Djavax.jdo.option.ConnectionUserName=hive -Djavax.jdo.option.ConnectionPassword=password" \
     --mount source=warehouse,target=/opt/hive/data/warehouse \
     --name metastore-standalone apache/hive:${HIVE_VERSION}
docker run -it -d -p 9083:9083 --env SERVICE_NAME=metastore --add-host=host.docker.internal:host-gateway \
     --env DB_DRIVER=mysql \
     --env SERVICE_OPTS="-Djavax.jdo.option.ConnectionDriverName=com.mysql.cj.jdbc.Driver  -Djavax.jdo.option.ConnectionURL=jdbc:mysql://host.docker.internal:3306/hive?createDatabaseIfNotExist=true -Djavax.jdo.option.ConnectionUserName=hive -Djavax.jdo.option.ConnectionPassword=password" \
     --mount source=warehouse,target=/opt/hive/data/warehouse \
     --name metastore-standalone apache/hive:${HIVE_VERSION}

Docker logs shows this for both drivers ( same error )

docker logs f3
+ : mysql
+ SKIP_SCHEMA_INIT=false
+ export HIVE_CONF_DIR=/opt/hive/conf
+ HIVE_CONF_DIR=/opt/hive/conf
+ '[' -d '' ']'
+ export 'HADOOP_CLIENT_OPTS= -Xmx1G -Djavax.jdo.option.ConnectionDriverName=com.mysql.cj.jdbc.Driver  -Djavax.jdo.option.ConnectionURL=jdbc:mysql://host.docker.internal:3306/hive?createDatabaseIfNotExist=true -Djavax.jdo.option.ConnectionUserName=hive -Djavax.jdo.option.ConnectionPassword=hive'
+ HADOOP_CLIENT_OPTS=' -Xmx1G -Djavax.jdo.option.ConnectionDriverName=com.mysql.cj.jdbc.Driver  -Djavax.jdo.option.ConnectionURL=jdbc:mysql://host.docker.internal:3306/hive?createDatabaseIfNotExist=true -Djavax.jdo.option.ConnectionUserName=hive -Djavax.jdo.option.ConnectionPassword=hive'
+ [[ false == \f\a\l\s\e ]]
+ initialize_hive
+ /opt/hive/bin/schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:	 jdbc:mysql://host.docker.internal:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver :	 com.mysql.cj.jdbc.Driver
Metastore connection User:	 hive
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
Underlying cause: java.lang.ClassNotFoundException : com.mysql.cj.jdbc.Driver
Use --verbose for detailed stacktrace.
*** schemaTool failed ***
+ '[' 1 -eq 0 ']'
+ echo 'Schema initialization failed!'
Schema initialization failed!
+ exit 1

What am I am doing wrong ?

I did try connecting to mysql from another Ubuntu container and I was able to make connection.

How do we know that docker image comes with mysql driver. In Readme, I see example of Postgres only but it says it can be used with Oracle, MySQL, MsSQL etc.
My Docker containers exits so I am unable to see what is inside Linux ? What do I do so that Docker doesn’t exit out since it can’t find mysql driver.

Please format your initial post according:

A properly formatted post is easier to read and makes it more likely that someone actually reads it, and responds to it.