A lightweight and configurable Oracle 12c Docker container
Due to Oracle licensing, you must manually download the Oracle 12c binaries from the Oracle website and agree to the Oracle license terms.
- Clone this repository
- Download the Oracle Database 12c binary
linuxx64_12201_database.zip
from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html - Put the zip in the base directory. Do not unzip it.
Build the image:
docker build --force-rm=true --no-cache=true --shm-size=1G -t steveswinsburg/oracle12c-ee .
On first run, the database will be provisioned. Using a basic command like docker run steveswinsburg/oracle12c-ee
will set defaults for everything and the database will not be persisted if you shut it down. You will also need to monitor the output to get the database password. This isn't ideal, so a more complete run command would look like:
docker run \
-p 1521:1521 -p 5500:5500 \
-e ORACLE_SID=orcl \
-e ORACLE_PWD=password \
-e ORACLE_MEM=4000 \
-v /opt/oracle/oradata \
-d \
steveswinsburg/oracle12c-ee
Check out the parameters below for a description of the options available.
Standard Parameters:
--name: The name of the container (default: auto generated)
-p: The port mapping of the host port to the container port.
Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express)
-e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB)
-e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)
-e ORACLE_MEM: The amount of memory in MB to allocate to Oracle. If you bump this up too much you might need to change your Docker settings to allocate more memory to Docker (default: 2048)
-v /opt/oracle/oradata
The data volume to use for the database.
Has to be writable by the Unix "oracle" (uid: 54321) user inside the container!
If omitted the database will not be persisted over container recreation.
-v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d/startup
Optional: A volume with custom scripts to be run after database startup.
For further details see the "Running scripts after setup and on startup" section below.
-v /opt/oracle/scripts/setup | /docker-entrypoint-initdb.d/setup
Optional: A volume with custom scripts to be run after database setup.
For further details see the "Running scripts after setup and on startup" section below.
-d: Run in detached mode. You want this otherwise Ctrl-C will kill the container.
Additional Parameters:
-e ORACLE_CHARACTERSET: The character set to use when creating the database (default: AL32UTF8)
-e ORACLE_CDB: Flag to create database as container database (default: false)
-e ORACLE_PDB: Specify the pdbname/pdbanme prefix if one or more pdb need to be created (default: None)
-e ORACLE_PDB_NUM: If PDB enabled, specify the number of PDB to be created (default: 0)
Once the container has been started you can connect to it like any other database. For example:
sqlplus sys/<your password>@//localhost:1521/<your SID> as sysdba
If you did not set the ORACLE_PWD
parameter, check the docker run output for the password.
The password for the SYS account can be changed via the docker exec command. Note, the container has to be running:
First run docker ps
to get the container ID. Then run:
docker exec <container id> ./setPassword.sh <new password>
First run docker ps
to get the container ID. Then run:
docker exec -it <container id> /bin/bash