oracle / docker-images

Official source of container configurations, images, and examples for Oracle products and projects
https://developer.oracle.com/use-cases/#containers
Universal Permissive License v1.0
6.51k stars 5.41k forks source link

Oracle 23c Free running on docker does not change ORACLE CHARACTERSET #2673

Closed cjacobm closed 1 year ago

cjacobm commented 1 year ago

Hello,

I´m running Docker version 20.10.25, build b82b9f3 in Amazon Linux 2. I downloaded the latest version of Oracle Free: docker pull container-registry.oracle.com/database/free:latest And after download, I executed this instruction:

docker run --name oraclefree -d --restart unless-stopped -p 1521:1521 -e ORACLE_PWD=ANYPASSWORD#09 -e ORACLE_CHARACTERSET=WE8ISO8859P15 -v /home/ec2-user/opt:/opt/oracle/oradata container-registry.oracle.com/database/free:latest

The instance was created with success, but the ORACLE CHARACTER SET not change, always is AL32UTF8. What could be wrong?

oraclesean commented 1 year ago

The createDB.sh script in this image sets the character set with the following code:

su -c 'sed -i -e "s|###ORACLE_CHARACTERSET###|$ORACLE_CHARACTERSET|g" /etc/sysconfig/"$CONF_FILE"'

This is similar to the replacement performed on the dbca.rsp response file. However, /etc/sysconfig/oracle-23c-free.conf expects CHARSET and doesn't contain the ###ORACLE_CHARACTERSET### template value:

<snip>
# Character set of the database
CHARSET=AL32UTF8
<snip>

The correct replacement string for a sysconfig-created database should be:

su -c 'sed -i -e "s|^CHARSET=.*$|CHARSET=$ORACLE_CHARACTERSET|g" /etc/sysconfig/"$CONF_FILE"'
yunus-qureshi commented 1 year ago

@oraclesean thanks. We'll check and fix this.

cjacobm commented 1 year ago

Thanks for the quick response. While the solution is not implemented, would there be any way around this limitation?

oraclesean commented 1 year ago

You can take the container you have and make the change to the dbCreate.sh script under /opt/oracle/scripts, then do a docker commit to save it as a new image. I can share details later today if that doesn't make sense.

oraclesean commented 1 year ago

To fix this in an existing image:

Please let me know if you encounter any issues with this method.

cjacobm commented 1 year ago

@oraclesean thanks for your response.

Based on your previous information, I tried another approach with what I already knew about docker.

I ran my previous command, and copied the file createDB.sh

docker container cp oraclefree:/opt/oracle/createDB.sh .

I changed the line, following your instructions:

# Creating database for FREE edition
if [ "${ORACLE_SID}" = "FREE" ]; then
  # Auto generate ORACLE PWD if not passed on
  export ORACLE_PWD=${ORACLE_PWD:-"$(openssl rand -hex 8)"}

  # Set character set
# su -c 'sed -i -e "s|###ORACLE_CHARACTERSET###|$ORACLE_CHARACTERSET|g" /etc/sysconfig/"$CONF_FILE"'
  su -c 'sed -i -e "s|^CHARSET=.*$|CHARSET=$ORACLE_CHARACTERSET|g" /etc/sysconfig/"$CONF_FILE"'
  # Creating Database
  su -c '/etc/init.d/oracle-free-23c configure << EOF
${ORACLE_PWD}
${ORACLE_PWD}
EOF
'

I killed the container (and database files) and ran the command again (I created a docker-compose.yml):

version: '3.8'

services:
  oraclefree:
    image: container-registry.oracle.com/database/free:latest
    container_name: oraclefree
    restart: unless-stopped
    ports:
      - "1521:1521"
    environment:
      - ORACLE_PWD=ANYPASSWORD#09
      - ORACLE_CHARACTERSET=WE8ISO8859P15
    volumes:
      - /home/ec2-user/opt:/opt/oracle/oradata
      - /home/ec2-user/createDB.sh:/opt/oracle/createDB.sh

And worked! Thank you very much! But, the solution presented by you is easier to implement. I'm going to test it out today. Obs: The same behavior happen in Oracle 21c Express.

oraclesean commented 1 year ago

@cjacobm great, glad to know you got it working! Thanks for catching this issue and for confirmation that it happens in 21c, too!

cjacobm commented 1 year ago

Hi @oraclesean

I followed the instructions (I believe there was a typo in the filename - I changed this file:oracle-free-23c.conf). But, when i run:

docker run --name oraclefree \
           -d --restart unless-stopped \
           -p 1521:1521 \
           -e ORACLE_PWD=ANYPASSWORD#09 \
           -e ORACLE_CHARACTERSET=WE8ISO8859P15 \
           -v /home/ec2-user/opt:/opt/oracle/oradata \
           <new image name>

It does not start the database creation scripts. It seems to me that he saved the state of the container by saving its last execution, which in this case was the bash execution. I ran docker inspect in the original image (I tried Google before), but I didn't find the instruction that I could use in the entrypoint parameter.

aditya059 commented 1 year ago

Hi @cjacobm We have raised a PR to resolve this. We will upload the new image soon. Thanks for catching this issue.

cjacobm commented 1 year ago

Thank you all! I'm waiting for the update.

aditya059 commented 1 year ago

Hi @cjacobm We have republished the image on container registry.