Executing the Shell Script through Dockerfile

Hi Support team, Please provide me inputs.
I am working on Snowflake to Kafka connectivity using jdbc connector. I have called the shell script jdbcsetup.sh file which is on my Desktop in my local machine via Docker commands. I am able to create the image and view it in Docker Desktop BUT I am not able to run the container. Log says jdbcsetup.sh: line 16: log: command not found, and status is 127. I believe it is not finding the .sh file path.

Docker file commands:

# Get the image
FROM confluentinc/cp-kafka-connect-base:7.3.1
LABEL maintainer="Vamshi"
USER root
COPY jdbcsetup.sh .
RUN chmod +x jdbcsetup.sh
CMD ["sh","jdbcsetup.sh"]

Shell script commands (jdbcsetup.sh file):

#!/bin/bash
set -e
log "Downloading snowflake-jdbc-3.13.26.jar"
wget https://repo1.maven.org/maven2/net/snowflake/snowflake-jdbc/3.13.4/snowflake-jdbc-3.13.26.jar

# https://docs.snowflake.com/en/user-guide/jdbc-configure.html#jdbc-driver-connection-string
CONNECTION_URL="jdbc:snowflake://dp8881.central-us.azure.snowflakecomputing.com/?warehouse=ED_WH(XS)&db=TEMP_DEV_ED&role=FR_IC_ANLYST&schema=DBO&user=IC_SERVICE_ACT&private_key_file=C:\Users\Downloads\rsa_key.p8&private_key_file_pwd=MIIEvAIBWLrnS6hUz/KhElKdJ4eYjU8KHICSj9TAuEEpNc2lg/uBMMF0J+cnPnilD6qxTyxiBdTlw+D9shA=="

curl -X PUT \
-H "Content-Type: application/json" \
--data '{
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"tasks.max": "1",
"connection.url": "'"$CONNECTION_URL"'",
"table.whitelist": "VW_CENTERENROLLMENT_IC",
"mode": "timestamp+incrementing",
"timestamp.column.name": "SUBMITDATE",
"incrementing.column.name": "Row",
"topic.prefix": "poc.stream.enrollments.changelog",
"validate.non.null": "false",
"errors.log.enable": "true",
"errors.log.include.messages": "true"
}' \
http://localhost:8083/connectors/jdbc-snowflake-source/config | jq .

sleep 15

log "Verifying topic"
timeout 60 docker exec connect kafka-avro-console-consumer -bootstrap-server broker:9092 --property schema.registry.url=https://hkc-66kzz.southcentralus.azure.confluent.cloud:9092 --topic poc.stream.enrollments.changelog --from-beginning --max-messages 3

Thank you.

try:

# Get the image
FROM confluentinc/cp-kafka-connect-base:7.3.1
LABEL maintainer="Vamshi"
USER root
COPY jdbcsetup.sh /jdbcsetup.sh
RUN chmod +x /jdbcsetup.sh
CMD ["/jdbcsetup.sh"]

You are not executing a shell script in your Dockerfile, you set the shell script as CMD for the container. It is recommended to use absolute paths in ENTRYPOINT (if declared) and CMD (if declared), as it ensures the files can be accessed.

Note: this is a community forum is mainly a place where users help users.