Last week at Dockercon, Oracle announced that the Oracle Database is now available alongside other Oracle products the on Docker Store.
Given how much folks here in Silicon Valley (including my better half) rave about how easy and great Docker is, I thought I would try it out and share with you exactly how I did.
Since I was a Docker virgin, the first thing I had to do was download and install Docker. Then, a quick trip to the Docker Store followed by a double click, and I was up and running!
Next, I needed to get the new Oracle Database container. Again, you have two options here:
- Go back to the Docker Store and search for “oracle database” which will return a Docker container with a 184.108.40.206 database but is not a persistent image. That means if you drop the container, the database disappears too. IIt’salso not possible to unplug the database from within the container and plug it in anywhere else.
- Go to Github, get an Oracle Docker build file, and go to Oracle.com and get the 12.2 database software. This combination will allow you to create a Docker container with the latest 12.2 database and persisted. That is to say, if the container is dropped, you still have the database, and it is possible to unplug the database and plug it in somewhere else.
I chose to go with option 2, which is a wee bit more involved but having 12.2 and a persistent image were both very important to me. And before you ask, yes, 12.2 will be made available in the Docker Store, and it will be persistent. IIt’sjust not there yet.
The steps below explain precisely what I did (with some help from @GeraldVenzl)
1. Go to https://github.com/oracle/docker-images and download the Oracle Docker build files.
2. Go to http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html and download Oracle Database 12c Release 2 for Linux x86-64.
3. You should now have two files:
Unzip the docker-images-master.zip file, which will result in a new directory called docker-images-master. This directory contains 12 subdirectories, one for each Oracle product supported on Docker.
unzip docker-images-master.zip Archive: docker-images-master.zip ce91c58275d24df32b3f5d3b8a68000ade61d562 creating: docker-images-master/ extracting: docker-images-master/.gitattributes inflating: docker-images-master/.gitignore inflating: docker-images-master/.gitmodules ... ... ... inflating: docker-images-master/README.md
4. Copy the 12.2 software (linuxx64_12201_database.zip) into the /docker-images-master/OracleDatabase/dockerfiles/220.127.116.11 subdirectory.
5. Next, you need to create the Docker image. I took the easy route and utilized the buildDockerImage.sh shell script, which is included in docker-images-master.zip. It will create an image using oraclelinux:7-slim and whichever database version you specify. I used the following command to install Oracle Database 12.2 software:
./buildDockerImage.sh -v 18.104.22.168 -e Checking if required packages are present and valid... linuxamd64_12201_database.zip: OK ===================== Building image 'oracle/database:22.214.171.124-ee' ... Sending build context to Docker daemon 2.688 GB
Note that the installer reaches out to the internet to get oraclelinux:7-slim and to do a yum update of the OS inside the container. If you are doing this behind a corporate firewall, you will need to explicitly set the environment variable https_proxy. The buildDockerImage.sh script will automatically detect http_proxy and https_proxy and pass it on to Docker to use for the image build.
6. Once the image is built you can check what you have by running the “docker images” command
docker images REPOSITORY TAG IMAGE ID CREATED SIZE oracle/database 126.96.36.199-ee 7c2999a16928 7 hours ago 14.8 GB oraclelinux 7-slim 442ebf722584 5 days ago 114 MB
As you can see, I have installed Oracle Linux and the Oracle Database 188.8.131.52 software. But, unfortunately, we don’t have a database yet.
7. To get an actual database, we need to create our first container. I used the “docker run” command below to do this and supplied a couple of additional parameters for mappings since I wanted to persist the database files even if the container was removed.
docker run --name oracle -p 1521:1521 -p 5500:5500 -v /Users/mcolgan-mac/oradata:/opt/oracle/oradata oracle/database:184.108.40.206-ee LSNRCTL for Linux: Version 220.127.116.11.0 - Production on 26-APR-2017 18:04:36 Copyright (c) 1991, 2016, Oracle. All rights reserved. Starting /opt/oracle/product/18.104.22.168/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 22.214.171.124.0 - Production System parameter file is /opt/oracle/product/126.96.36.199/dbhome_1/network/admin/listener.ora Log messages written to /opt/oracle/diag/tnslsnr/75ca99d5275d/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=75ca99d5275d)(PORT=1521))) Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ :
–name Gave the new container the name “oracle”(will be auto-generated if omitted)
-p Mapped port 1521 and 5500 on my laptop to the corresponding ports inside the container
-v Mapped my local directory (/Users/mcolgan-mac/oradata ) to the default location where the data files will be stored (:/opt/oracle/oradata) to ensure the files are persisted outside my container.
8. The “docker run” command calls the Oracle DBCA and automatically creates a database. Since this is a 12c database, it will automatically create a container database ORCLCDB and one pluggable database ORCLPDB1 (both can be overwritten if you wish).
I didn’t specify a password for the SYS, SYSTEM or PDBADMIN accounts in my command, so one was automatically generated for me and displayed in the output of the command. Be sure to change the password from this default. Using the “docker exec” command, you can do this once your database is up and running.
docker exec oracle ./setPassword.sh XXXXXX
9. We can confirm that our container was created successfully and is running using the “docker ps” command.
docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 75ca99d5275d oracle/database:188.8.131.52-ee "/bin/sh -c 'exec ..." 8 hours ago Up 5 hours 0.0.0.0:1521/tcp oracle
10. Going forward, all we need to do is start and stop the container, which will open and close the database.
docker start oracle docker stop oracle
You can monitor exactly what is going during these commands by looking at the docker logs using the docker log command.
docker logs oracle LSNRCTL for Linux: Version 184.108.40.206.0 - Production on 27-APR-2017 18:58:05 Copyright (c) 1991, 2016, Oracle. All rights reserved. Starting /opt/oracle/product/220.127.116.11/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 18.104.22.168.0 - Production System parameter file is /opt/oracle/product/22.214.171.124/dbhome_1/network/admin/listener.ora Log messages written to /opt/oracle/diag/tnslsnr/75ca99d5275d/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=75ca99d5275d)(PORT=1521))) Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 126.96.36.199.0 - Production Start Date 27-APR-2017 18:58:05 Uptime 0 days 0 hr. 0 min. 2 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /opt/oracle/product/188.8.131.52/dbhome_1/network/admin/listener.ora Listener Log File /opt/oracle/diag/tnslsnr/75ca99d5275d/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=75ca99d5275d)(PORT=1521))) The listener supports no services The command completed successfully SQL*Plus: Release 184.108.40.206.0 Production on Thu Apr 27 18:58:08 2017 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to an idle instance. SQL> ORACLE instance started. Total System Global Area 1610612736 bytes Fixed Size 8793304 bytes Variable Size 520094504 bytes Database Buffers 1073741824 bytes Redo Buffers 7983104 bytes Database mounted. Database opened. SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 220.127.116.11.0 - 64bit Production ######################### DATABASE IS READY TO USE! ######################### ORCLPDB1(3):Database Characterset for ORCLPDB1 is AL32UTF8 2017-04-27T18:58:20.468112+00:00 ORCLPDB1(3):Opatch validation is skipped for PDB ORCLPDB1 (con_id=0) 2017-04-27T18:58:21.545187+00:00 ORCLPDB1(3):Opening pdb with no Resource Manager plan active Pluggable database ORCLPDB1 opened read write Starting background process CJQ0 Completed: ALTER DATABASE OPEN 2017-04-27T18:58:22.163089+00:00 CJQ0 started with pid=40, OS id=262 2017-04-27T18:58:22.589640+00:00 Shared IO Pool defaulting to 64MB. Trying to get it from Buffer Cache for process 81. =========================================================== Dumping current patch information =========================================================== No patches have been applied =========================================================== 2017-04-27T18:58:23.381214+00:00 db_recovery_file_dest_size of 12780 MB is 0.00% used. This is a user-specified limit on the amount of space that will be used by this database for recovery-related files, and does not reflect the amount of space available in the underlying filesystem or ASM diskgroup.
So there you have it, ten simple steps to get you up and running with Oracle Database 12.2 on Docker. If you want more details on building Oracle Database Docker images, check out GGerald’sblog.
28 thoughts on “Oracle Database 12c now available on Docker”
./buildDockerImage.sh –v 18.104.22.168 –e
Checking if required packages are present and valid…
Building image ‘oracle/database:22.214.171.124-ee’ …
Sending build context to Docker daemon 2.688 GB
126.96.36.199 ~ 188.8.131.52 ???
You caught me!
I forgot to capture the screen output for this step, so I stole some from Gerald’s blog without realizing he had installed 184.108.40.206 and not 220.127.116.11. LOL!
I’ve gone ahead and corrected the mistake!
Thanks for keeping me honest,
As I see, you have installed this on your mac. Which is lightweight and preferred?Virtual box or docker?
I’ve used virtual box exclusively in the past but I’m slowly converting over to using Docker now.
With my Oracle Database environments I wouldn’t consider either option lightweight as they both require a minimum of 2GB of DRAM.
My basic rule of thumb is virtual box for older versions of the Oracle Database, 11gR1 etc. as those images are readily available and Docker for newer stuff.
I am able to set DB and I have few questions:
1. how I can login into this DB as a sysadmin and what will be the password.
2. how can know service_name of this DB.
On the first startup of the container a random password will be generated for the database if one was not provided. You can find this password in the output line:
ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN:
You can also change the password for those accounts via the docker exec command. Note, the container has to be running before you do this:
use the below command to login as pdbadmin user:
docker exec -ti oracle-ee sqlplus pdbadmin@ORCLPDB1
I’m using windows 10 and Docker Tool box.
I’m able create image, run and connect to database with out data volume creation.
If i try to do with data volume creation, i’m getting below errors.
Please guide me.
mkdir: cannot create directory ‘/opt/oracle/oradata/dbconfig’: Permission denied
mv: cannot stat ‘/opt/oracle/product/18.104.22.168/dbhome_1/dbs/spfilegkp.ora’: No such file or directory
mv: cannot stat ‘/opt/oracle/product/22.214.171.124/dbhome_1/dbs/orapwgkp’: No such file or directory
mv: cannot move ‘/opt/oracle/product/126.96.36.199/dbhome_1/network/admin/sqlnet.ora’ to ‘/opt/oracle/oradata/dbconfig/gkp/’: No such file or directory
mv: cannot move ‘/opt/oracle/product/188.8.131.52/dbhome_1/network/admin/listener.ora’ to ‘/opt/oracle/oradata/dbconfig/gkp/’: No such file or directory
mv: cannot move ‘/opt/oracle/product/184.108.40.206/dbhome_1/network/admin/tnsnames.ora’ to ‘/opt/oracle/oradata/dbconfig/gkp/’: No such file or directory
cp: cannot create regular file ‘/opt/oracle/oradata/dbconfig/gkp/’: No such file or directory
ln: failed to create symbolic link ‘/opt/oracle/product/220.127.116.11/dbhome_1/network/admin/sqlnet.ora’: File exists
ln: failed to create symbolic link ‘/opt/oracle/product/18.104.22.168/dbhome_1/network/admin/listener.ora’: File exists
ln: failed to create symbolic link ‘/opt/oracle/product/22.214.171.124/dbhome_1/network/admin/tnsnames.ora’: File exists
cp: cannot stat ‘/opt/oracle/oradata/dbconfig/gkp/oratab’: No such file or directory
########### E R R O R ###############
DATABASE SETUP WAS NOT SUCCESSFUL!
Please check output for further info!
########### E R R O R ###############
The following output is now a tail of the alert.log:
tail: cannot open ‘/opt/oracle/diag/rdbms/*/*/trace/alert*.log’ for reading: No such file or directory
tail: no files remaining
I got the same error
Do you solve it?
I am not sure if I miss something
I found the solution for this error in the next link
I knew that it was a permission issue but I thought was in the container side. Anyway…
Basically you have to grant permission of read and write to the folder where the file will be stored.
I used this command:
Could you please tell how you have created the docker container without the volume switch (-v)
Thank you for this clear and very useful guide. I had no problems getting it working.
However, there is a problem with native compilation of PLSQL objects. Compilation works fine in “interpreted” mode, but with “native” mode it gets the following Internal Error:
ORA-00600: internal error code, arguments: [pesldl03_MMap: errno 1 errmsg
Operation not permitted
This is covered in metalink article 1625010.1, where it says that /dev/shm needs to be mounted with rw and exec permissions and without noexec or nosuid.
Is there a way to do this in the docker image, or when the container starts up (ie before starting the DB)?
Yes you should be able to do it with a command similar to this:
docker run –name test -v /dev/shm –tmpfs /dev/shm:rw,nosuid,nodev,exec,size=1g -p 1521:1521 -v /home/oracle/oradata:/opt/oracle/oradata oracle/database:126.96.36.199-ee
More details making change to the /dec/shm permissions and size can be found on github https://github.com/oracle/docker-images/issues/223.
Thanks for the write up. I have completed all the steps you have given above successfully.
How do I now start working on the oracle database – I mean creating tables and all?
In Gerald’s blog, he says to use “sql system/LetsDocker@//localhost:1521/ORCLPDB1” to connect to the DB. How do I do the same in mac? It is telling me “sql command not found.”
ssh into the running Docker image and run sqlplus from there, or install SQLDeveloper on your OSX host system.
Hi Maria, a question about oracle-database-11 on docker, can it be done with builddockerimage.sh. I tried but 11g have archive of two files, when i run builddockerimage.sh i got an error like ‘missing files in folder 188.8.131.52’ , i run like buildDockerImage.sh -v 184.108.40.206 -e
Hi Maria, thank you for this guide, I want to ssh oracle user from other linux server, but i coudn’t find how.
I’m getting the following error from buildDockerImage.sh –
Building image ‘oracle/database:220.127.116.11-ee’ …
Sending build context to Docker daemon 3.454GB
Step 1/17 : FROM oraclelinux:7-slim
Get https://registry-1.docker.io/v2/library/oraclelinux/manifests/7-slim: unauthorized: incorrect username or password
There was an error building the image.
Any idea what could be causing that?
Never mind. Solved it. I had to do a
$ docker login
from my command shell before running the script.
Ok, it seems I had a old version of docker and this parameter start-period for HEALTHCHECK option in dockerfile is available from 17.05 onwards. I have 17.04 installed. The solution is to either remove the HEALTHCHECK option from dockerfile, or remove the start-period parameter from the HEALTHCHECK option or upgrade the docker to 17.05 onwards.
See – https://github.com/oracle/docker-images/issues/676
I am getting the following error while creating the image . Could you help me with this .
—> Running in 80129a4b716c
Removing intermediate container 80129a4b716c
Step 4/17 : ENV INSTALL_DIR $ORACLE_BASE/install PATH $ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:$PATH LD_LIBRARY_PATH $ORACLE_HOME/lib:/usr/lib CLASSPATH $ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
—> Running in f19c5fc4a6ec
Removing intermediate container f19c5fc4a6ec
Step 5/17 : COPY $INSTALL_FILE_1 $INSTALL_FILE_2 $INSTALL_RSP $PERL_INSTALL_FILE $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
Removing intermediate container f6a053631abd
devmapper: Error mounting ‘/dev/mapper/docker-253:3-6292555-d8a22e7866427d7232a3ab403380a6de78d8d898ecc59e79628d8740b1871be5’ on ‘/var/lib/docker/devicemapper/mnt/d8a22e7866427d7232a3ab403380a6de78d8d898ecc59e79628d8740b1871be5’: input/output error
ERROR: Oracle Database Docker Image was NOT successfully created.
ERROR: Check the output and correct any reported problems with the docker build operation.
I have tried to install windows Oracle DB (Microsoft Windows x64 (64-bit)) its failed because its expecting to copy linux binaries even though i install windows binaries.
could you able to assist if i m missing something.
Step 5/17 : COPY $INSTALL_FILE_1 $INSTALL_FILE_2 $INSTALL_RSP $PERL_INSTALL_FILE
$SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
COPY failed: stat /mnt/sda1/var/lib/docker/tmp/docker-builder174664057/linuxamd6
4_12102_database_1of2.zip: no such file or directory
ERROR: Oracle Database Docker Image was NOT successfully created.
ERROR: Check the output and correct any reported problems with the docker build
I did pretty much exactly this on Docker for Mac, only difference is I used docker-compose with following YAML file:
occs:description=Official Oracle DB Enterprise. View the logs on the button
It all SEEMS to work, except any data I add to database is lost any time i stop the container and restart. No idea what the solution is.
you can mount persistent storage as described here
Quick question on this, is there anyway to access the Enterprise Manager when Oracle is installed in Docker? Thanks in advance
Oracle EM Express is available with Oracle Database in Docker by default, once you forward port 5500 because it doesn’t need an agent. However, the full-blown Enterprise Manager tool would require you to install and configure the EM agent.