Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Oracle XE 11 Docker image without license issues

Script to convert the official zipped Oracle XE RPM archive to DEB. The script also creates a Dockerfile with the correct file names.

Download the Oracle XE .rpm.zip archive from http://www.oracle.com/ and put it into the same folder as Dockerfile.template

Run the script convert-oracle-xe-rpm.sh to convert the downloaded archive and to create Dockerfile

You can use

docker build --tag=wnameless/oracle-xe-11g .

to create a new version of the official Docker image by wnameless yourself.

#!/bin/bash
convert() { # archive
declare archive="$1"
rm -f oracle-xe_*.deb??
rm -rf Disk1 || exit 1
unzip "$archive" || exit 1
cd Disk1 || exit 1
rpmName=(*.rpm)
rpmName="${rpmName[0]}"
echo "Converting RPM -> DEB. Note: This command can take 10 minutes to execute"
sudo alien --scripts --to-deb "$rpmName" || exit 1
files=(oracle-xe_*.deb)
debName="${files[0]}"
split --bytes=100m "$debName" "$debName"
mv *.deb?? ..
cd ..
}
updateDockerfile() {
files=(oracle-xe_*.deb)
debName="${files[0]}"
gawk \
--assign basename=$(basename "$debName" .deb) \
--assign parts="$(ls *.deb??)" \
'/@PARTS@/ {
split(parts, a, /\n/);
for(part in a) {
printf("ADD %s /\n", a[part]);
}
next;
}
/@BASENAME@/ {
gsub(/\@BASENAME\@/, basename);
print $0;
next;
}
{ print; }' \
Dockerfile.template > Dockerfile
}
files=(oracle-xe-*.rpm.zip)
if [[ ${#files[@]} -gt 1 ]]; then
echo "ERROR: Found ${#files[@]} RPMs"
for f in "${files[@]}"; do
echo " $f"
done
echo "Please delete the old ones or rename them to *.bak"
exit 1
fi
archive="${files[0]}"
if [[ ! -f "$archive" ]]; then
echo "ERROR: Unable to find Oracle XE RPM.ZIP; please download it from oracle.com"
exit 1
fi
convert "$archive"
updateDockerfile
echo "SUCCESS"
ls -al *.deb??
exit 0
FROM ubuntu:14.04.1
MAINTAINER Wei-Ming Wu <wnameless@gmail.com>
ADD chkconfig /sbin/chkconfig
ADD init.ora /
ADD initXETemp.ora /
@PARTS@
RUN cat /@BASENAME@.deb?? > /@BASENAME@.deb
# Install sshd
RUN apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:admin' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
RUN echo "export VISIBLE=now" >> /etc/profile
# Prepare to install Oracle
RUN apt-get install -y libaio1 net-tools bc
RUN ln -s /usr/bin/awk /bin/awk
RUN mkdir /var/lock/subsys
RUN chmod 755 /sbin/chkconfig
# Install Oracle
RUN dpkg --install /@BASENAME@.deb
RUN mv /init.ora /u01/app/oracle/product/11.2.0/xe/config/scripts
RUN mv /initXETemp.ora /u01/app/oracle/product/11.2.0/xe/config/scripts
RUN printf 8080\\n1521\\noracle\\noracle\\ny\\n | /etc/init.d/oracle-xe configure
RUN echo 'export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe' >> /etc/bash.bashrc
RUN echo 'export PATH=$ORACLE_HOME/bin:$PATH' >> /etc/bash.bashrc
RUN echo 'export ORACLE_SID=XE' >> /etc/bash.bashrc
# Remove installation files
RUN rm /@BASENAME@.deb*
EXPOSE 22
EXPOSE 1521
EXPOSE 8080
CMD sed -i -E "s/HOST = [^)]+/HOST = $HOSTNAME/g" /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora; \
service oracle-xe start; \
/usr/sbin/sshd -D
I hereby grant everyone to take this code and use it any way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment