Skip to content

Instantly share code, notes, and snippets.

@slezhnin
Last active May 6, 2020 13:26
Show Gist options
  • Save slezhnin/6326973c6370a1796e04ef18cc335202 to your computer and use it in GitHub Desktop.
Save slezhnin/6326973c6370a1796e04ef18cc335202 to your computer and use it in GitHub Desktop.
oracle-run.sh
#!/bin/sh
# Run the Oracle Database in a Docker Container
# See https://github.com/oracle/docker-images
# The Docker repo name
# Use "oracle/database" if you've built images from the git repo above.
# This is my private repo.
REPO="sirius1/dev"
# The database version prefix
# Just comment it if you use dedicated (or local) repo.
VERSION_PREFIX="oracle-database-"
# Uncomment if you want to see the commands to be echoed only
#DEBUG_PREFIX="echo"
# If you run with clean volume than you would want to set the password.
# Like this: START_PWD=123 sh oracle-run.sh 19
# This will activate the password option&
if [ -n "$START_PWD" ]; then
START_PWD="-e ORACLE_PWD=$START_PWD"
fi
# Command line variables depending on version argument
IMAGE_PREFIX="$REPO:$VERSION_PREFIX"
case $1 in
11)
DB_VERSION="11.2.0.2-xe"
NAME="oracle-11-xe"
OPTS="--shm-size=1g"
PORTS="-p 1521:1521"
;;
12)
DB_VERSION="12.2.0.1-se2"
NAME="oracle-12-se2"
OPTS=""
PORTS="-p 1521:1521 -p 5500:5500"
;;
18)
DB_VERSION="18.4.0-xe"
NAME="oracle-18-xe"
OPTS=""
PORTS="-p 1521:1521 -p 5500:5500"
;;
19)
DB_VERSION="19.3.0-se2"
NAME="oracle-19-se2"
OPTS=""
PORTS="-p 1521:1521 -p 5500:5500"
;;
*)
echo "Unsupported database version $1"
exit 1
;;
esac
shift;
# Run the Docker commands
$DEBUG_PREFIX docker volume create --label $NAME $NAME
$DEBUG_PREFIX docker run --rm -l $NAME --name=$NAME $OPTS $PORTS $START_PWD -v $NAME:/opt/oracle/oradata $* $IMAGE_PREFIX$DB_VERSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment