Creating an Oracle Database Docker image

Oracle_Docker

Oracle has released Docker build files for the Oracle Database on Github. With those build files one can go ahead and build his or her own Docker image for the Oracle Database. If you don’t know what Docker is you should go and check it out. It’s a cool technology based on the Linux containers technology that allows you to containerize your application, whatever that application may be. Naturally, it didn’t take long for people to start looking at containerizing databases as well which makes a lot of sense, especially for, but not only, development and test environments. Here is a detailed blog post on how to containerize your Oracle Database by using those build files that Oracle has provided.

What you need

Environment

My environment is as follows:

  • Oracle Linux 7.3 (4.1.12-94.3.8.el7uek.x86_64)
  • Docker 17.03.1-ce (docker-engine.x86_64 17.03.1.ce-3.0.1.el7)
  • Oracle Database 12.2.0.1 Enterprise Edition

Docker setup

The first thing, if not already done so, is to setup Docker on the environment. Luckily this is fairly straight forward. Docker is shipped as an addon with Oracle Linux 7 UEK4. As I’m running on such environment all I have to do is to is to enable the addons yum repository and install the docker-engine package. Note, this is done as the root Linux user:

Enable OL7 addons repo

[root@localhost ~]# yum-config-manager enable *addons*
Loaded plugins: langpacks
================================================================== repo: ol7_addons ==================================================================
[ol7_addons]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7Server
baseurl = http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/7Server/ol7_addons
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = True
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7Server/ol7_addons/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7Server/ol7_addons/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
hdrdir = /var/cache/yum/x86_64/7Server/ol7_addons/headers
http_caching = all
includepkgs =
ip_resolve =
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid =
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink =
minrate = 0
mirrorlist =
mirrorlist_expire = 86400
name = Oracle Linux 7Server Add ons (x86_64)
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/7Server/ol7_addons
pkgdir = /var/cache/yum/x86_64/7Server/ol7_addons/packages
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 30.0
ui_id = ol7_addons/x86_64
ui_repoid_vars = releasever,
basearch
username =

Install docker-engine

[root@localhost ~]# yum install docker-engine
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:17.03.1.ce-3.0.1.el7 will be installed
--> Processing Dependency: docker-engine-selinux >= 17.03.1.ce-3.0.1.el7 for package: docker-engine-17.03.1.ce-3.0.1.el7.x86_64
--> Running transaction check
---> Package selinux-policy-targeted.noarch 0:3.13.1-102.0.3.el7_3.16 will be updated
---> Package selinux-policy-targeted.noarch 0:3.13.1-166.0.2.el7 will be an update
--> Processing Dependency: selinux-policy = 3.13.1-166.0.2.el7 for package: selinux-policy-targeted-3.13.1-166.0.2.el7.noarch
--> Running transaction check
---> Package selinux-policy.noarch 0:3.13.1-102.0.3.el7_3.16 will be updated
---> Package selinux-policy.noarch 0:3.13.1-166.0.2.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================
Installing:
docker-engine x86_64 17.03.1.ce-3.0.1.el7 ol7_addons 19 M
Updating:
selinux-policy-targeted noarch 3.13.1-166.0.2.el7 ol7_latest 6.5 M
Updating for dependencies:
selinux-policy noarch 3.13.1-166.0.2.el7 ol7_latest 435 k

Transaction Summary
======================================================================================================================================================
Install 1 Package
Upgrade 1 Package (+1 Dependent package)

Total download size: 26 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for ol7_latest
(1/3): selinux-policy-3.13.1-166.0.2.el7.noarch.rpm | 435 kB 00:00:00
(2/3): selinux-policy-targeted-3.13.1-166.0.2.el7.noarch.rpm | 6.5 MB 00:00:01
(3/3): docker-engine-17.03.1.ce-3.0.1.el7.x86_64.rpm | 19 MB 00:00:04
------------------------------------------------------------------------------------------------------------------------------------------------------
Total 6.2 MB/s | 26 MB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : selinux-policy-3.13.1-166.0.2.el7.noarch 1/5
Updating : selinux-policy-targeted-3.13.1-166.0.2.el7.noarch 2/5
Installing : docker-engine-17.03.1.ce-3.0.1.el7.x86_64 3/5
Cleanup : selinux-policy-targeted-3.13.1-102.0.3.el7_3.16.noarch 4/5
Cleanup : selinux-policy-3.13.1-102.0.3.el7_3.16.noarch 5/5
Verifying : selinux-policy-targeted-3.13.1-166.0.2.el7.noarch 1/5
Verifying : selinux-policy-3.13.1-166.0.2.el7.noarch 2/5
Verifying : docker-engine-17.03.1.ce-3.0.1.el7.x86_64 3/5
Verifying : selinux-policy-targeted-3.13.1-102.0.3.el7_3.16.noarch 4/5
Verifying : selinux-policy-3.13.1-102.0.3.el7_3.16.noarch 5/5

Installed:
docker-engine.x86_64 0:17.03.1.ce-3.0.1.el7

Updated:
selinux-policy-targeted.noarch 0:3.13.1-166.0.2.el7

Dependency Updated:
selinux-policy.noarch 0:3.13.1-166.0.2.el7

Complete!

And that’s it! Docker is now installed on the machine. Before I proceed with building an image I first have to configure my environment appropriately.

Enable non-root user

The first thing I want to do is to enable a non-root user to communicate with the Docker engine. Enabling a non-root user is fairly straight forward as well. When Docker was installed a new Unix group docker was created along with it. If you want to allow a user to communicate with the Docker daemon directly, hence avoiding to run as the root user, all you have to do is to add that user to the docker group. In my case I want to add the oracle user to that group:

[root@localhost ~]# id oracle
uid=1000(oracle) gid=1001(oracle) groups=1001(oracle),1000(dba)
[root@localhost ~]# usermod -a -G docker oracle
[root@localhost ~]# id oracle
uid=1000(oracle) gid=1001(oracle) groups=1001(oracle),1000(dba),981(docker)

Increase base image size

Before I go ahead and run the image build I want to double check one important parameter: The default base image size for the Docker container. In the past Docker came with a maximum container size of 10 GB by default. While this is more than enough for running some applications inside Docker containers this needed to be increased for Oracle Database. The Oracle Database 12.2.0.1 image requires about 13GB of space for the image build.

Recently the default size has been increased to 25GB which will be more than enough for the Oracle Database image. The setting can be found and double checked in /etc/sysconfig/docker-storage as the storage-opt dm.basesize parameter:

[root@localhost ~]# cat /etc/sysconfig/docker-storage
# This file may be automatically generated by an installation program.

# By default, Docker uses a loopback-mounted sparse file in
# /var/lib/docker. The loopback makes it slower, and there are some
# restrictive defaults, such as 100GB max storage.

# If your installation did not set a custom storage for Docker, you
# may do it below.

# Example: Use a custom pair of raw logical volumes (one for metadata,
# one for data).
# DOCKER_STORAGE_OPTIONS = --storage-opt dm.metadatadev=/dev/mylogvol/my-docker-metadata --storage-opt dm.datadev=/dev/mylogvol/my-docker-data
DOCKER_STORAGE_OPTIONS= --storage-driver devicemapper --storage-opt dm.basesize=25G

Start and enable the Docker service

The final step is to start the docker service and configure it to start at boot time. This is done via the systemctl command:

[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/docker.service.d
└─docker-sysconfig.conf
Active: active (running) since Sun 2017-08-20 14:18:16 EDT; 5s ago
Docs: https://docs.docker.com
Main PID: 19203 (dockerd)
Memory: 12.8M
CGroup: /system.slice/docker.service
├─19203 /usr/bin/dockerd --selinux-enabled --storage-driver devicemapper --storage-opt dm.basesize=25G
└─19207 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state...

As a last step you can verify the setup and the base image size (check for Base Device Size:) via docker info:

[root@localhost ~]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 17.03.1-ce
Storage Driver: devicemapper
Pool Name: docker-249:0-202132724-pool
Pool Blocksize: 65.54 kB
Base Device Size: 26.84 GB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 14.42 MB
Data Space Total: 107.4 GB
Data Space Available: 47.98 GB
Metadata Space Used: 581.6 kB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.147 GB
Thin Pool Minimum Free Space: 10.74 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.135-RHEL7 (2016-11-16)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc
runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe
init version: 949e6fa
Security Options:
seccomp
Profile: default
selinux
Kernel Version: 4.1.12-94.3.8.el7uek.x86_64
Operating System: Oracle Linux Server 7.3
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 7.795 GiB
Name: localhost.localdomain
ID: D7CR:3DGV:QUGO:X7EB:AVX3:DWWW:RJIA:QVVT:I2YR:KJXV:ALR4:WLBV
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

That concludes the installation of Docker itself.

Building the Oracle Database Docker image

Now that Docker is up and running I can start building the image. First I need to get the Docker build files and the Oracle install binaries, both are easy to obtain as shown below. Note that I use the oracle Linux user for all the following steps, which I have enabled previously to communicate with the Docker daemon:

Obtaining the required files

Github build files

First I have to download the Docker build files. There are various ways to do this. I can for example clone the Git repository directly. But for simplicity and for the people who aren’t familiar with git I will just use the download option on Github itself. If you go to the main repository URL https://github.com/oracle/docker-images/ you will see a green button saying “Clone or download” and by clicking on it you will have the option “Download ZIP“. Alternatively you can also just download the repository directly via the static URL: https://github.com/oracle/docker-images/archive/master.zip


[oracle@localhost ~]$ wget https://github.com/oracle/docker-images/archive/master.zip
--2017-08-20 14:31:32-- https://github.com/oracle/docker-images/archive/master.zip
Resolving github.com (github.com)... 192.30.255.113, 192.30.255.112
Connecting to github.com (github.com)|192.30.255.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/oracle/docker-images/zip/master [following]
--2017-08-20 14:31:33-- https://codeload.github.com/oracle/docker-images/zip/master
Resolving codeload.github.com (codeload.github.com)... 192.30.255.120, 192.30.255.121
Connecting to codeload.github.com (codeload.github.com)|192.30.255.120|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: ‘master.zip’

[ ] 4,411,616 3.37MB/s in 1.2s

2017-08-20 14:31:34 (3.37 MB/s) - ‘master.zip’ saved [4411616]

[oracle@localhost ~]$ unzip master.zip
Archive: master.zip
21041a743e4b0a910b0e51e17793bb7b0b18efef
creating: docker-images-master/
extracting: docker-images-master/.gitattributes
inflating: docker-images-master/.gitignore
inflating: docker-images-master/.gitmodules
inflating: docker-images-master/CODEOWNERS
inflating: docker-images-master/CONTRIBUTING.md
...
...
...
creating: docker-images-master/OracleDatabase/
extracting: docker-images-master/OracleDatabase/.gitignore
inflating: docker-images-master/OracleDatabase/COPYRIGHT
inflating: docker-images-master/OracleDatabase/LICENSE
inflating: docker-images-master/OracleDatabase/README.md
creating: docker-images-master/OracleDatabase/dockerfiles/
...
...
...
inflating: docker-images-master/README.md
[oracle@localhost ~]$

Oracle installation binaries

For the Oracle binaries just download them from where you usually would download them. Oracle Technology Network is probably the place that most people go to. Once you have downloaded them you can proceed with building the image:

[oracle@localhost ~]$ ls -al *database*zip
-rw-r--r--. 1 oracle oracle 1354301440 Aug 20 14:40 linuxx64_12201_database.zip

Building the image

Now that I have all the files it’s time to build the Docker image. You will find a separate README.md in the docker-images-master/OracleDatabase/SingleInstance directory which explains the build process in more details. Make sure that you always read that file as it will always reflect the latest changes in the build files! You will also find a buildDockerImage.sh shell script in the docker-images-master/OracleDatabase/SingleInstance/dockerfiles directory that does the legwork of the build for you. For the build it is essential that I copy the install files into the correct version directory. As I’m going to create an Oracle Database 12.2.0.1 image I need to copy the install zip file into docker-images-master/OracleDatabase/SingleInstance/dockerfiles/12.2.0.1:

[oracle@localhost ~]$ cd docker-images-master/OracleDatabase/SingleInstance/dockerfiles/12.2.0.1/
[oracle@localhost 12.2.0.1]$ cp ~/linuxx64_12201_database.zip .
[oracle@localhost 12.2.0.1]$ ls -al
total 3372832
drwxrwxr-x. 2 oracle oracle 4096 Aug 20 14:44 .
drwxrwxr-x. 5 oracle oracle 77 Aug 19 00:35 ..
-rwxr-xr-x. 1 oracle oracle 1259 Aug 19 00:35 checkDBStatus.sh
-rwxr-xr-x. 1 oracle oracle 909 Aug 19 00:35 checkSpace.sh
-rw-rw-r--. 1 oracle oracle 62 Aug 19 00:35 Checksum.ee
-rw-rw-r--. 1 oracle oracle 62 Aug 19 00:35 Checksum.se2
-rwxr-xr-x. 1 oracle oracle 2964 Aug 19 00:35 createDB.sh
-rw-rw-r--. 1 oracle oracle 9203 Aug 19 00:35 dbca.rsp.tmpl
-rw-rw-r--. 1 oracle oracle 6878 Aug 19 00:35 db_inst.rsp
-rw-rw-r--. 1 oracle oracle 2550 Aug 19 00:35 Dockerfile.ee
-rw-rw-r--. 1 oracle oracle 2552 Aug 19 00:35 Dockerfile.se2
-rwxr-xr-x. 1 oracle oracle 2261 Aug 19 00:35 installDBBinaries.sh
-rw-r--r--. 1 oracle oracle 3453696911 Aug 20 14:45 linuxx64_12201_database.zip
-rwxr-xr-x. 1 oracle oracle 6151 Aug 19 00:35 runOracle.sh
-rwxr-xr-x. 1 oracle oracle 1026 Aug 19 00:35 runUserScripts.sh
-rwxr-xr-x. 1 oracle oracle 769 Aug 19 00:35 setPassword.sh
-rwxr-xr-x. 1 oracle oracle 879 Aug 19 00:35 setupLinuxEnv.sh
-rwxr-xr-x. 1 oracle oracle 689 Aug 19 00:35 startDB.sh
[oracle@localhost 12.2.0.1]$

Now that the zip file is in place I am ready to invoke the buildDockerImage.sh shell script in the dockerfiles folder. The script takes a couple of parameters, -v for the version and -e for telling it that I want Enterprise Edition. Note: The build of the image will pull the Oracle Linux slim base image and execute a yum install as well as a yum upgrade inside the container. For it to success to have to have internet connectivity:

[oracle@localhost 12.2.0.1]$ cd ..
[oracle@localhost dockerfiles]$ ./buildDockerImage.sh -v 12.2.0.1 -e
Checking if required packages are present and valid...
linuxx64_12201_database.zip: OK
==========================
DOCKER info:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 17.03.1-ce
Storage Driver: devicemapper
Pool Name: docker-249:0-202132724-pool
Pool Blocksize: 65.54 kB
Base Device Size: 26.84 GB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 14.42 MB
Data Space Total: 107.4 GB
Data Space Available: 47.98 GB
Metadata Space Used: 581.6 kB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.147 GB
Thin Pool Minimum Free Space: 10.74 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.135-RHEL7 (2016-11-16)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc
runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe
init version: 949e6fa
Security Options:
seccomp
Profile: default
selinux
Kernel Version: 4.1.12-94.3.8.el7uek.x86_64
Operating System: Oracle Linux Server 7.3
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 7.795 GiB
Name: localhost.localdomain
ID: D7CR:3DGV:QUGO:X7EB:AVX3:DWWW:RJIA:QVVT:I2YR:KJXV:ALR4:WLBV
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
==========================
Building image 'oracle/database:12.2.0.1-ee' ...
Sending build context to Docker daemon 3.454 GB
Step 1/16 : FROM oraclelinux:7-slim
7-slim: Pulling from library/oraclelinux
3152c71f8d80: Pull complete
Digest: sha256:e464042b724d41350fb3ac2c2f84bd9d28d98302c9ebe66048a5367682e5fad2
Status: Downloaded newer image for oraclelinux:7-slim
---> c0feb50f7527
Step 2/16 : MAINTAINER Gerald Venzl
---> Running in e442cae35367
---> 08f875cea39d
...
...
...

Step 15/16 : EXPOSE 1521 5500
---> Running in 4476c1c236e1
---> d01d39e39920
Removing intermediate container 4476c1c236e1
Step 16/16 : CMD exec $ORACLE_BASE/$RUN_FILE
---> Running in 8757674cc3d5
---> 98129834d5ad
Removing intermediate container 8757674cc3d5
Successfully built 98129834d5ad

Oracle Database Docker Image for 'ee' version 12.2.0.1 is ready to be extended:

--> oracle/database:12.2.0.1-ee

Build completed in 802 seconds.

Starting and connecting to the Oracle Database inside a Docker container

Once the build was successful I can now start and run the Oracle Database inside a Docker container. All I have to do is to issue the docker run command and pass in the appropriate parameters. One important parameter is the -p for the mapping of ports inside the container to the outside world. This is required so that I can also connect to the database from outside the Docker container. Another important parameter is the -v parameter which allows me to keep the data files of the database in a location outside the Docker container. This is important as it will allow me to preserve my data even when the container is thrown away. You should always use the -v parameter or create a named Docker volume! The last useful parameter that I’m going to use is the --name parameter which specifies the name of the Docker container itself. If omitted a random name will be generated. However, passing on a name will allow me to refer to the container via that name later on:

[oracle@localhost dockerfiles]$ cd ~
[oracle@localhost ~]$ mkdir oradata
[oracle@localhost ~]$ chmod a+w oradata
[oracle@localhost ~]$ docker run --name oracle-ee -p 1521:1521 -v /home/oracle/oradata:/opt/oracle/oradata oracle/database:12.2.0.1-ee
ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: 3y4RL1K7org=1

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 20-AUG-2017 19:07:55

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Starting /opt/oracle/product/12.2.0.1/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/e3d1a2314421/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 20-AUG-2017 19:07:56
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/e3d1a2314421/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The listener supports no services
The command completed successfully
[WARNING] [DBT-10102] The listener configuration is not selected for the database. EM DB Express URL will not be accessible.
CAUSE: The database should be registered with a listener in order to access the EM DB Express URL.
ACTION: Select a listener to be registered or created with the database.
Copying database files
1% complete
13% complete
25% complete
Creating and starting Oracle instance
26% complete
30% complete
31% complete
35% complete
38% complete
39% complete
41% complete
Completing Database Creation
42% complete
43% complete
44% complete
46% complete
47% complete
50% complete
Creating Pluggable Databases
55% complete
75% complete
Executing Post Configuration Actions
100% complete
Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.

SQL*Plus: Release 12.2.0.1.0 Production on Sun Aug 20 19:16:01 2017

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>
System altered.

SQL>
Pluggable database altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
Completed: alter pluggable database ORCLPDB1 open
2017-08-20T19:16:01.025829+00:00
ORCLPDB1(3):CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
ORCLPDB1(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
ORCLPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2017-08-20T19:16:01.889003+00:00
ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl' SCOPE=SPFILE;
ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
Completed: ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE

On the very first startup of the container a new database is being created. Subsequent startups of the same container or newly created containers pointing to the same volume will just start up the database again. Once the database is created and or started the container will run a tail -f on the Oracle Database alert.log file. This is done for convenience so that issuing a docker logs command will actually print the logs of the database running inside that container. Once the database is created or started up you will see the line DATABASE IS READY TO USE! in the output. After that you can connect to the database.

Resetting the database admin accounts passwords

The startup script also generated a password for the database admin accounts. You can find the password next to the line ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: in the output. You can either use that password going forward or you can reset it to a password of your choice. The container provides a script called setPassword.sh for resetting the password. In a new shell just execute following command against the running container:

[oracle@localhost ~]$ docker exec oracle-ee ./setPassword.sh LetsDocker
The Oracle base remains unchanged with value /opt/oracle

SQL*Plus: Release 12.2.0.1.0 Production on Sun Aug 20 19:17:08 2017

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>
User altered.

SQL>
User altered.

SQL>
Session altered.

SQL>
User altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

Connecting to the Oracle Database

Now that the container is running and the port 1521 mapped to the outside world I can connect to the database inside the container:

[oracle@localhost ~]$ sql system/LetsDocker@//localhost:1521/ORCLPDB1

SQLcl: Release 4.2.0 Production on Sun Aug 20 19:56:43 2017

Copyright (c) 1982, 2017, Oracle. All rights reserved.

Last Successful login time: Sun Aug 20 2017 12:21:42 -07:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> grant connect, resource to gvenzl identified by supersecretpwd;

Grant succeeded.

SQL> conn gvenzl/supersecretpwd@//localhost:1521/ORCLPDB1
Connected.
SQL>

Stopping the Oracle Database Docker container

If you wish to stop the Docker container you can just do so via the docker stop command.  All you will have to do is to issue the command and pass on the container name or id. This will trigger the container to issue a shutdown immediate for the database inside the container. By default Docker will only allow 10 seconds for the container to shutdown before killing it. For applications that may be fine but for persistent containers such as the Oracle Database container you may want to give the container a bit more time to shutdown the database appropriately. You can do that via the -t option that allows you to pass on a new timeout in seconds for the container to shutdown successfully. I will give the database 30 seconds to shutdown but it’s important to point out that it doesn’t really matter how long you give the container to shutdown. Once the database is shutdown the container will exit normal. It will not wait all the seconds that you have specified until returning control. So even if you give it 10 minutes (600 seconds) it will still return as soon as the database is shutdown. Just keep that in mind when specifying a timeout for busy database containers:

[oracle@localhost ~]$ docker stop -t 30 oracle-ee
oracle-ee

Restarting the Oracle Database Docker container

A stopped container can always be restarted via the docker start command:

[oracle@localhost ~]$ docker start oracle-ee
oracle-ee

The docker start command will put the container into background and return control immediately. You can check the status of the container via the docker logs command which should print the same DATABASE IS READY TO USE! line. You will also see that this time the database was just restarted rather than created. Note, a docker logs -f will follow the log output, i.e. keep on printing new lines:

[oracle@localhost ~]$ docker logs oracle-ee
...
...
...
SQL*Plus: Release 12.2.0.1.0 Production on Sun Aug 20 19:30:31 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 12.2.0.1.0 - 64bit Production
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
ORCLPDB1(3):Undo initialization finished serial:0 start:6800170 end:6800239 diff:69 ms (0.1 seconds)
ORCLPDB1(3):Database Characterset for ORCLPDB1 is AL32UTF8
ORCLPDB1(3):Opatch validation is skipped for PDB ORCLPDB1 (con_id=0)
ORCLPDB1(3):Opening pdb with no Resource Manager plan active
2017-08-20T19:30:43.703897+00:00
Pluggable database ORCLPDB1 opened read write

Now that the database is up and running again I can connect once more to the database inside:

[oracle@localhost ~]$ sql gvenzl/supersecretpwd@//localhost:1521/ORCLPDB1

SQLcl: Release 4.2.0 Production on Sun Aug 20 20:10:28 2017

Copyright (c) 1982, 2017, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select sysdate from dual;

SYSDATE
---------
20-AUG-17

SQL> exit

Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

Summary

This concludes how to containerize the Oracle Database using Docker. Note that Oracle has also provided build files for other Oracle Database versions and editions. The steps described above are largely the same but you should always refer to the README.md that comes with the build files. In there you will also find more options for how to run your Oracle Database containers.

Github repository: https://github.com/oracle/docker-images/tree/master/OracleDatabase

51 thoughts on “Creating an Oracle Database Docker image

  1. Hi Gjorgi,

    I am creating an Oracle 12.1.0.2 docker image on RHEL 7.4.
    However during the installation i get the below error message:
    ——————————————————————————————————————-
    Step 11/17 : RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && $ORACLE_HOME/root.sh && rm -rf $INSTALL_DIR
    —> Running in 461871045fa5
    Changing permissions of /opt/oracle/oraInventory.
    Adding read,write permissions for group.
    Removing read,write,execute permissions for world.

    Changing groupname of /opt/oracle/oraInventory to dba.
    The execution of the script is complete.
    Check /opt/oracle/product/12.1.0.2/dbhome_1/install/root_461871045fa5_2018-01-05_10-48-10.log for the output of root script
    rm: cannot remove ‘/opt/oracle/install’: Directory not empty
    Removing intermediate container 461871045fa5
    The command ‘/bin/sh -c $ORACLE_BASE/oraInventory/orainstRoot.sh && $ORACLE_HOME/root.sh && rm -rf $INSTALL_DIR’ returned a non-zero code: 1
    There was an error building the image.
    ——————————————————————————————————————-
    The directory /opt is empty and there is no oracle folder, do let me know if I am missing something?

    Thanks a lot.

    Like

  2. Hello, Gerald.
    Can I specify the name of the database that will be created inside the container, the first time it starts?
    For some tests that I’m doing on an application, I need the database to have a specific name.

    Like

  3. hi.
    thank you so much
    i want it to ask can i use the same docker file but with oracle database for AIX or windows ??

    Like

    1. Hi fatiha,

      As long as Docker runs on those platforms you will be able to run Docker containers on them, regardless what software is contained within the Docker containers. That’s the beauty of Docker. 🙂

      I know that Windows works for sure, AIX I don’t know.

      Thx,

      Like

      1. OK THANK YOU
        but there is a problem because when i work inside the container then commit the changes it gives me an image with size bigger then the first.i push it to my local registry. now i have two images of oracledatabase with the first is with the tag V1 and the second with V2,
        is there any possibilities to delete the first image with V1 tag and only keep working with the second V2?
        is it gonna work or i always have to keep the previous version,cause i don’t have enough space to keep all images.
        my second question is when i creat a table inside the container ,where can i find the data of the table that i created?

        Like

        1. Hi fatiha,

          Regarding the size, it depends what you are doing inside the container. If you modify or put files into the container, of course the commit will increase the image size. But why are you committing the container to begin with? What’s the use case for that?

          Yes, you can delete the v1 version if you don’t need that one any longer. v2 will be it’s own full version which doesn’t need v1 any longer.

          What do you mean the data of that table? The data is within the table and you can select it via SQL. Physically the table is stored in a tablespace which has one or more data files associated with itself. Within those data files the data of the table is stored on disk.

          You might want to have a look at https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance/samples. Perhaps some of those samples help you on what you are trying to do.

          Thx,

          Like

  4. How do i configure the custom NLS parameters as it is conflicting with a dump import . I want to set the language to German and terrority as Germany but by default it is American and America. Any help is appreciated.

    Like

  5. Hi,

    Is there any tip on how to remote connect to the oracle database on a container, from a different host than the host that the oracle container is running? Is there any article about that?

    Thank you

    Like

    1. Hi Mariana,

      I don’t have an article as such but it’s a great suggestion, thanks very much for that!

      Do you try to connect the database container from a different container within a VM on the same machine or from an actual cluster like Swarm or Kubernetes or similar?

      Thx,

      Like

      1. Hi Gerald,

        Thank you for your reply!
        We are trying to connect from a different container on another host, using an app running on a container.
        I have an oracle container running on Host 1 and an app container running on Host 2. But we are having a hard time to reach the database.
        Another question, what is the Host IP I should use on my listener configuration? The container ip (using docker inspect to get the info?

        Thank you!

        Like

        1. Hi Mariana,

          Are you using any clustering technology with that or just two machines with two containers? The reason why I ask is to understand whether your container on the second machine can even reach the first machine.

          As long at the port is exposed “-p :1521”, everything reaching your host port should be automatically forwarded into the container.

          For the listener, make sure that the host is 0.0.0.0, that means that the listener is accepting traffic from any IP/name. Container host names are the same as the container names, and they may change. Also the IP may change. So easiest is 0.0.0.0, unless you have a deterministic way for the host name. Do not use 127.0.0.1, that way the listener is only listening inside the container.

          Thx,

          Like

  6. Hi Gerald,

    first of all thank you for this very good post and all the information! Really helped me to step into the whole topic of running oracle db in docker.
    I have one question – when I start the buildDockerImage.sh it reaches step 11/24:

    Step 11/24 : COPY –chown=oracle:dba $INSTALL_FILE_1 $INSTALL_RSP $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/

    At some point I wonder, how long the step takes, since I am waiting in fron of my machine almost an hour, and from top it seems that the process sleeps – anything that could block the process?

    Thanks,
    Daniel

    Like

    1. Hi Daniel,

      Thank you very much! 🙂

      That step shouldn’t take longer than a few minutes, if even. During the execution of that step Docker is copying the installer zip file and response file into the image.
      Can it be that Docker is somehow throttled on the I/O? Does the step finish successfully after the hour, or does it die?

      Thx,

      Like

      1. Hi Gerald,

        sorry for the late response – I got it working and now it works perfect.
        I don’t know exactly all the thinks I did, but I think I increased memory and file handles on my vm.

        Thanks,
        Daniel

        Like

  7. Hi Gerald,
    I had followed the above mentioned steps for creating Single Node database on the docker. I have enabled SSL and loaded some schemas in it. I have stopped the database and took the image of it and pushed it into docker registry. Now on the another linux box, when i run docker cmd, i get the below error. COuld you please let us know on how to resolve this issue.

    [sjothili@den01dza ~]$ docker run –name oracledb-ssl-jan2 -p 1521:1521 -p 2484:2484 -v /scratch/sjothili/oradata:/opt/oracle/oradata sjothili/oracle-ssl-db-sampleschema-uploaded
    ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: C1O1WkFBNlg=1

    LSNRCTL for Linux: Version 12.2.0.1.0 – Production on 02-JAN-2019 11:18:15

    Copyright (c) 1991, 2016, Oracle. All rights reserved.

    Starting /opt/oracle/product/12.2.0.1/dbhome_1/bin/tnslsnr: please wait…

    TNSLSNR for Linux: Version 12.2.0.1.0 – Production
    System parameter file is /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
    Log messages written to /opt/oracle/diag/tnslsnr/c910a60e9ac7/listener/alert/log.xml
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))

    STATUS of the LISTENER

    Alias LISTENER
    Version TNSLSNR for Linux: Version 12.2.0.1.0 – Production
    Start Date 02-JAN-2019 11:18:15
    Uptime 0 days 0 hr. 0 min. 0 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
    Listener Log File /opt/oracle/diag/tnslsnr/c910a60e9ac7/listener/alert/log.xml
    Listening Endpoints Summary…
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
    The listener supports no services
    The command completed successfully
    [WARNING] [DBT-10328] Specified GDB Name (ORCLCDB) may have a potential conflict with an already existing database on the system.
    ACTION: Specify a different GDB Name that does not conflict with existing databases on the system.
    [FATAL] [DBT-10317] Specified SID Name (ORCLCDB) already exists.
    ACTION: Specify a different SID Name that does not already exist.
    [ 2018-12-21 07:03:12.510 UTC ] Copying database files
    DBCA_PROGRESS : 1%
    DBCA_PROGRESS : 13%
    DBCA_PROGRESS : 25%
    [ 2018-12-21 07:04:41.169 UTC ] Creating and starting Oracle instance
    DBCA_PROGRESS : 26%
    DBCA_PROGRESS : 30%
    DBCA_PROGRESS : 31%
    DBCA_PROGRESS : 35%
    DBCA_PROGRESS : 38%
    DBCA_PROGRESS : 39%
    [ 2018-12-21 07:07:36.698 UTC ] ORA-29283: invalid file operation
    ORA-06512: at “SYS.DBMS_QOPATCH”, line 1547
    ORA-06512: at “SYS.UTL_FILE”, line 536
    ORA-29283: invalid file operation
    ORA-06512: at “SYS.UTL_FILE”, line 41
    ORA-06512: at “SYS.UTL_FILE”, line 478
    ORA-06512: at “SYS.DBMS_QOPATCH”, line 1532
    ORA-06512: at “SYS.DBMS_QOPATCH”, line 1417
    ORA-06512: at line 1

    DBCA_PROGRESS : 41%
    [ 2018-12-21 07:07:42.223 UTC ] Completing Database Creation
    DBCA_PROGRESS : 42%
    DBCA_PROGRESS : 43%
    DBCA_PROGRESS : 44%
    DBCA_PROGRESS : 46%
    DBCA_PROGRESS : 47%
    DBCA_PROGRESS : 50%
    [ 2018-12-21 07:09:29.202 UTC ] Creating Pluggable Databases
    DBCA_PROGRESS : 55%
    DBCA_PROGRESS : 75%
    [ 2018-12-21 07:09:36.266 UTC ] Executing Post Configuration Actions
    DBCA_PROGRESS : 100%
    [ 2018-12-21 07:09:36.267 UTC ] Database creation complete. For details check the logfiles at:
    /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
    Database Information:
    Global Database Name:ORCLCDB
    System Identifier(SID):ORCLCDB

    SQL*Plus: Release 12.2.0.1.0 Production on Wed Jan 2 11:18:29 2019

    Copyright (c) 1982, 2016, Oracle. All rights reserved.

    Connected to an idle instance.

    SQL> ALTER SYSTEM SET control_files=’/opt/oracle/oradata/ORCLCDB/control01.ctl’ scope=spfile
    *
    ERROR at line 1:
    ORA-01034: ORACLE not available
    Process ID: 0
    Session ID: 0 Serial number: 0

    SQL> ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
    *
    ERROR at line 1:
    ORA-01034: ORACLE not available
    Process ID: 0
    Session ID: 0 Serial number: 0

    SQL> Disconnected
    mkdir: cannot create directory ‘/opt/oracle/oradata/dbconfig’: Permission denied
    mv: cannot stat ‘/opt/oracle/product/12.2.0.1/dbhome_1/dbs/spfileORCLCDB.ora’: No such file or directory
    mv: cannot stat ‘/opt/oracle/product/12.2.0.1/dbhome_1/dbs/orapwORCLCDB’: No such file or directory
    mv: cannot move ‘/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/sqlnet.ora’ to ‘/opt/oracle/oradata/dbconfig/ORCLCDB/’: No such file or directory
    mv: cannot move ‘/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora’ to ‘/opt/oracle/oradata/dbconfig/ORCLCDB/’: No such file or directory
    mv: cannot move ‘/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/tnsnames.ora’ to ‘/opt/oracle/oradata/dbconfig/ORCLCDB/’: No such file or directory
    cp: cannot create regular file ‘/opt/oracle/oradata/dbconfig/ORCLCDB/’: No such file or directory
    ln: failed to create symbolic link ‘/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/sqlnet.ora’: File exists
    ln: failed to create symbolic link ‘/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora’: File exists
    ln: failed to create symbolic link ‘/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/tnsnames.ora’: File exists
    cp: cannot stat ‘/opt/oracle/oradata/dbconfig/ORCLCDB/oratab’: No such file or directory
    The Oracle base remains unchanged with value /opt/oracle
    #####################################
    ########### 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:
    Archiving is disabled
    2018-12-21T16:38:40.739928+00:00
    JIT: pid 333 requesting stop
    2018-12-21T16:38:41.784931+00:00
    ARCH: Archival disabled due to shutdown: 1089
    Shutting down archive processes
    Archiving is disabled
    JIT: pid 333 requesting stop
    2018-12-21T16:38:41.806277+00:00
    Stopping background process VKTM

    Like

  8. Is it possible to run multiple instance of oracle 12.2.0.1 container on a single docker host? With each instance pointing to a separate database?

    Like

    1. Yes, it is. You can spin up as many instances pointing to their own database, as you like. All you have to do is to issue another docker run command and make sure the host port is mapped to a free port.

      Like

  9. Hi Gerald,

    Thank you so much for this most useful post, sharing knowledge and detailed explanation 🙂

    When i shared this post with my team members they have couple of questions and i need your help to answer those questions:
    VM with docker will help to create docker image. Couple of questions here:
    1. Where will host that image? What are deployment steps and how to setup communication?
    2. What is base image you are going to use to create new image?
    3. What will be dockerfile commands/sequence needed for creating new image?
    4. How can we reuse the new image in another host?
    5. How the above process will be a benefit for a Oracle database administrator (or) from the application perspective?

    I will wait for your reply.
    Thank you!!

    Regards,
    Malli

    Like

    1. Hi Malli,

      1. Where will host that image? What are deployment steps and how to setup communication?
        The image will be hosted to wherever you have configured in Docker.
      2. What is base image you are going to use to create new image?
        It’s the oraclelinux:7-slim image (https://github.com/oracle/docker-images/blob/master/OracleDatabase/SingleInstance/dockerfiles/19.3.0/Dockerfile#L23)

      3. What will be dockerfile commands/sequence needed for creating new image?
        See https://github.com/oracle/docker-images/blob/master/OracleDatabase/SingleInstance/dockerfiles/19.3.0/Dockerfile

      4. How can we reuse the new image in another host?
        Just like any other Docker image you can share or export/move it to a different environment.

      5. How the above process will be a benefit for a Oracle database administrator (or) from the application perspective?
        That depends entirely on what the DBA or application is after.

      Thx,

      Like

  10. Hello Gerald,Thank you very much for the post. I tried the same and i am getting an error with Docker Version
    ./buildDockerImage.sh -v 12.2.0.1 -e

    [oracle@docker dockerfiles]$ ./buildDockerImage.sh -v 12.2.0.1 -e
    Docker version is below the minimum required version 17.09
    Please upgrade your Docker installation to proceed.

    Like

    1. Hi Vidhyapriya,

      Your Docker version is below the minimum required version 17.09
      Please upgrade your Docker installation to proceed.

      Like

  11. Hello Gerald, I have a issuse:
    when I run this step:
    ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: VVTcSObwPBw=1

    LSNRCTL for Linux: Version 12.2.0.1.0 – Production on 19-JUN-2019 05:37:23

    Copyright (c) 1991, 2016, Oracle. All rights reserved.

    Starting /opt/oracle/product/12.2.0.1/dbhome_1/bin/tnslsnr: please wait…

    TNSLSNR for Linux: Version 12.2.0.1.0 – Production
    System parameter file is /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
    Log messages written to /opt/oracle/diag/tnslsnr/803d2176ec8d/listener/alert/log.xml
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))

    STATUS of the LISTENER

    Alias LISTENER
    Version TNSLSNR for Linux: Version 12.2.0.1.0 – Production
    Start Date 19-JUN-2019 05:37:28
    Uptime 0 days 0 hr. 0 min. 5 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
    Listener Log File /opt/oracle/diag/tnslsnr/803d2176ec8d/listener/alert/log.xml
    Listening Endpoints Summary…
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
    The listener supports no services
    The command completed successfully
    [WARNING] [DBT-10102] The listener configuration is not selected for the database. EM DB Express URL will not be accessible.
    CAUSE: The database should be registered with a listener in order to access the EM DB Express URL.
    ACTION: Select a listener to be registered or created with the database.
    Copying database files
    1% complete
    13% complete
    25% complete
    Creating and starting Oracle instance
    26% complete
    30% complete
    31% complete
    35% complete
    38% complete
    39% complete
    41% complete
    Completing Database Creation
    42% complete
    43% complete
    44% complete
    46% complete
    47% complete
    50% complete
    Creating Pluggable Databases
    55% complete
    75% complete
    Executing Post Configuration Actions
    100% complete
    Look at the log file “/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log” for furt her details.

    SQL*Plus: Release 12.2.0.1.0 Production on Wed Jun 19 05:54:45 2019

    Copyright (c) 1982, 2016, Oracle. All rights reserved.

    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production

    SQL>
    System altered.

    SQL>
    Pluggable database altered.

    SQL>
    PL/SQL procedure successfully completed.

    SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production
    The Oracle base remains unchanged with value /opt/oracle
    #########################
    DATABASE IS READY TO USE!
    #########################
    The following output is now a tail of the alert.log:
    2019-06-19T05:54:40.042712+00:00
    ORCLPDB1(3):CREATE SMALLFILE TABLESPACE “USERS” LOGGING DATAFILE ‘/opt/oracle/ oradata/ORCLCDB/ORCLPDB1/users01.dbf’ SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MA XSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
    2019-06-19T05:54:41.336933+00:00
    ORCLPDB1(3):Completed: CREATE SMALLFILE TABLESPACE “USERS” LOGGING DATAFILE ‘/ opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf’ SIZE 5M REUSE AUTOEXTEND ON NEX T 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT A UTO
    ORCLPDB1(3):ALTER DATABASE DEFAULT TABLESPACE “USERS”
    ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE “USERS”
    2019-06-19T05:54:46.162835+00:00
    ALTER SYSTEM SET control_files=’/opt/oracle/oradata/ORCLCDB/control01.ctl’ SCOPE =SPFILE;
    ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
    Completed: ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
    2019-06-19T06:03:13.320713+00:00
    ORCLPDB1(3):Resize operation completed for file# 10, old size 337920K, new size 358400K
    2019-06-19T07:03:17.476373+00:00
    Resize operation completed for file# 3, old size 471040K, new size 481280K

    I waiting verry long time (4~5 hour), but this step is not done.
    I do not understand it, when did this step finish?

    Like

    1. Hi Ducnv,

      The Docker container is running and the database ready to be used, as printed:

      #########################
      DATABASE IS READY TO USE!
      #########################
      The following output is now a tail of the alert.log:
      

      As long as the Docker container is running this prompt will print the alert.log. As soon as you stop it, the prompt will exit and return control.

      That’s just how Docker works. If you want to have control back immediately, you have to call the docker command with the “-d, –detach” option. See the Docker run reference for more information.

      Like

      1. Dear Gerald,

        Step: –> Connecting to the Oracle Database
        I have error :
        $ sql system/LetsDocker@//localhost:1521/ORCLPDB1
        bash: sql: command not found…
        How to fix it ?

        Like

          1. Hi Gerald,
            Case1:
            I use the below command to login as system user:
            docker exec -ti oracle-ee sqlplus system@ORCLPDB1
            Case2:
            I tried, install SQLcl or SQL*Plus or connect via other tools like SQL Developer
            It worked.
            Thank You.

            Like

  12. What about data inside oracle database. If i commit data in database will it be persistent in oracle database inside a container? What about the .dbf file. Where to keep these?

    Like

      1. Hi Gerald,
        May I know after I setup the docker and oracle database container, can I restore database restore traditional oracle database into the oracle database container?

        Like

        1. Hi Poo yap,

          I assume so but probably with some headaches. What you have inside the container is a full-on Oracle Database install just like on any Linux environment.

          But to restore, you probably have to ssh into the container and make the backup visible via another volume.

          You could, of course, also extend the image and build a new one that performs the restore for you.

          Thx,

          Like

  13. Hi Gerald,
    I did all the Steps you mentioned in the blog,Now need to access enterprise manager,It is asking https://localhost:5500 is requesting your username and password. The site says: “XDB”,What is theuser name and password to enter enterprise manager.I tried SYS,SYSTEM,PDBADMIN.i didn’t resolved the problem.Could you please help me to enter the EM.
    Thanks in Advance brother.

    Like

  14. Hey Gerald,
    I`m having a really hard time editing my tnsnames.ora file, is this impossible in docker? The least i could do was to copy the file via docker cp, and when i did, it was empty. Please assist.

    Like

    1. Hi Prosper,

      It is possible in different ways, but why do you need the tnsnames.ora file to begin with, I wonder?

      Usually, once the DB is up and running, a client should just connect using its local tnsnames.ora file, just like as if the database container was a server somewhere else.

      But you can also just overwrite $ORACLE_HOME/network/admin to point to a volume with a tnsnames.ora in it, or mount a volume anywhere and set the $TNS_ADMIN variable to that location. For a more permanent solution you could even just extend the image itself with a new tnsnames.ora file as well.

      Thx,

      Like

  15. Hello Gerald, I need your help, I am trying to build an image of oracle 19c on aws ec2. What permissions do i need to give to start with to build the image successfully.

    Like

    1. Hi Acd,

      That highly depends on what OS and with what container runtime you are trying to build the image.

      It’s probably best to ask the question on the GitHub repo directly. It’s been a while since I have been involved with these images.

      Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.