Skip to content

Instantly share code, notes, and snippets.

@anjumjfax
Last active July 19, 2021 10:54
Show Gist options
  • Save anjumjfax/0cb8e63f32fb2a04bc81776d41098fd3 to your computer and use it in GitHub Desktop.
Save anjumjfax/0cb8e63f32fb2a04bc81776d41098fd3 to your computer and use it in GitHub Desktop.
Install Oracle 11g on Ubuntu (Debian, Mint, etc) through Docker
#!/usr/bin/env bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
apt install -y alien libaio1 curl docker.io
curl https://download.oracle.com/otn_software/linux/instantclient/211000/oracle-instantclient-basiclite-21.1.0.0.0-1.x86_64.rpm > /tmp/basiclite.rpm
curl https://download.oracle.com/otn_software/linux/instantclient/211000/oracle-instantclient-sqlplus-21.1.0.0.0-1.x86_64.rpm > /tmp/sqlplus.rpm
curl https://download.oracle.com/otn_software/linux/instantclient/211000/oracle-instantclient-devel-21.1.0.0.0-1.x86_64.rpm > /tmp/sdk.rpm
alien --install /tmp/*.rpm
docker pull oracleinanutshell/oracle-xe-11g
docker run -d -p 49161:1521 oracleinanutshell/oracle-xe-11g
container_name=$(sudo docker container list | awk '{ if($2 == "oracleinanutshell/oracle-xe-11g") { print $NF } }')
docker rename "$container_name" oracle
docker stop oracle
touch /etc/systemd/system/oracle.service
/bin/cat > /etc/systemd/system/oracle.service <<EOF
[Unit]
Description=Oracle Container
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a oracle
ExecStop=/usr/bin/docker stop -t 2 oracle
[Install]
WantedBy=default.target
EOF
systemctl daemon-reload
systemctl enable oracle.service
systemctl start oracle.service
systemctl status oracle.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment