Closed cjacobm closed 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"'
@oraclesean thanks. We'll check and fix this.
Thanks for the quick response. While the solution is not implemented, would there be any way around this limitation?
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.
To fix this in an existing image:
fix_sysconfig
) in an interactive shell as the root
user:
docker run -it --name fix_sysconfig -u root container-registry.oracle.com/database/free:latest bash
CHARSET
in /etc/sysconfig/oracle-23c-free.conf
to CHARSET=###ORACLE_CHARACTERSET###
. (You could also change it to CHARSET=WE8ISO8859P15
if you don't need the flexibility of passing a value during docker run
.)docker commit fix_sysconfig <new image name>
When you run docker images
you'll see the newly created image. Use your original docker run
command, but substitute the new image name:
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>
When starting this image, the initialization process sees the modified configuration file and performs the replacement (or sees a hardcoded value) and you should get the result you need.
Please let me know if you encounter any issues with this method.
@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.
@cjacobm great, glad to know you got it working! Thanks for catching this issue and for confirmation that it happens in 21c, too!
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.
Hi @cjacobm We have raised a PR to resolve this. We will upload the new image soon. Thanks for catching this issue.
Thank you all! I'm waiting for the update.
Hi @cjacobm We have republished the image on container registry.
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?