Introduction
During DockerCon 2017 Oracle announced support for Oracle 12.1 Database docker images – see press release: Oracle Brings Oracle’s Flagship Databases and Developer Tools to the Docker Store. In this Post I will detail how you can use the excellent new Oracle docker image to rapidly deploy an Oracle 12c database within a container and then extend the container to use persistent storage provided by a Pure Storage FlashArray, by default the Oracle 12c docker image provides non-persistent storage (see Oracle limitation statement below).
Limit statement: from docker store
docker delete
This image does not support Docker volumes! The database inside the Docker image stores all data in non-persistent storage. When the container is deleted, all data in this container will be deleted as well. Delete the container with caution.
Our Oracle 12c database docker container will enjoy all the benefits of a Pure Storage FlashArray including low latency performance, space efficient crash consistent snapshots and will not require any local storage.
Getting Started
Before we try and ‘pull’ the new Oracle 12c docker image we will need to create a Docker account, login to the Docker Store, and complete the Oracle form, providing your name, company, phone number and then accept the Oracle license agreement. You can now download the Oracle 12c Database Docker images from the Docker Store using your credentials.
.
The ‘Setup Instructions’ button provides details on how ‘pull’ the image and also how to set-up the your Oracle database within Docker.
1 |
docker pull store/oracle/database–enterprise:12.1.0.2 |
The Docker image includes all the required Oracle files so is pretty large coming in at ~5.2GB, so it may take a while to download.
Use the docker image command to list installed images.
1 |
$ docker images |
Creating docker volumes
Before I run my Oracle 12c docker container I will create 4 volume to support the following database layout:
/u01 – OraInventory and Oracle 12c product directories
/u02 – Oracle Datafile
/u03 – Fast Recovery Area
/u04 – RedoLog files.
I have already installed the Pure Storage docker volume plug-in and have documented this here, to create the 4 volumes we will use the docker volume create command providing name, size and label. e.g.
1 2 3 4 |
docker volume create —driver=pure —opt size=20GB —name=PSTG–u01 —label=product docker volume create —driver=pure —opt size=100GB —name=PSTG–u02 —label=oradata docker volume create —driver=pure —opt size=200GB —name=PSTG–u03 —label=fast_recovery_area docker volume create —driver=pure —opt size=10GB —name=PSTG–u04 —label=redo |
We can use the docker volume ls command with a filter to list the 4 database volumes we are interested in using the following syntax
1 |
$ docker volume ls –f name=<name> |
The Pure Storage Docker Plugin also supports docker volume inspect, from here we can see the labels which we defined earlier, great way to see where and what the mount is being used for. e.g.
1 |
$ docker volume inspect <volume name> |
Now that we have installed the Oracle 12c docker image and created the our 4 database volumes we are ready to create our Oracle 12c container using the docker run command with -v to present our newly created volumes to our container.
Running the Container
Before we can use the Oracle Docker image we just downloaded we must first create an environment file as documented in the ‘Setup Instructions’ and customise the environment file updating the database name, password, domain and feature bundle as required.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
DB_SID=PSTG ## db passwd ## default : Oracle DB_PASSWD=Oracle ## db domain ## default : localdomain DB_DOMAIN=localdomain ## db bundle ## default : basic ## valid : basic / high / extreme ## (high and extreme are only available for enterprise edition) DB_BUNDLE=basic ## end |
We will use the docker run command to start our Oracle database docker
1 |
$ docker run –d —env–file <path_to_env_file> –p <listener_port>:1521 –p <http_port>:5500 –it —name <container_name> —shm–size=“<shared_memory_size>” –v <volume name> <image_name> |
Parameters:
-d – run docker container in background (detached)
–env-file <path_to_env_file> environment file you created using above example.
-p <listener_port> is the port on host machine to map the container’s 1521 port (listener port).
-p <http_port> is the port on host machine to map the container’s 5500 port (http service port).
–name <container_name> container name you want to create
–shm-size <shared_memory_size> container memory size, minimum requirement is 4GB e.g. –shm-size=”4g”
-v <volume name : mount point>
<image_name> name of Oracle image download to be used to create container.
In this example our environment file is called PSTG_env.dat and our container is going to be called PSTG
1 2 3 4 5 6 7 8 9 |
$ docker run –d —env–file ./PSTG_env.dat \ –p 1527:1521 –p 5507:5500 \ –it —name PSTG \ –v PSTG–u01:/u01 \ –v PSTG–u02:/u02 \ –v PSTG–u03:/u03 \ –v PSTG–u04:/u04 \ —shm–size=8g \ store/oracle/database–enterprise:12.1.0.2 |
We can monitor progress of the build using docker logs providing the docker name.
1 |
$ docker logs –f PSTG |
Once the container has started we can now connect to it and check out our Oracle 12c environment using the docker exec command and container name
1 |
$ docker exec –it PSTG /bin/bash |
From within our Oracle 12c ‘PSTG’ docker container we can see our Pure Storage volumes (/u01, /u02, /u03 & /u04) and the sizes we specified.
From sqlplus we can now see our persistent Oracle data files.