Running Oracle 18 database in a docker container on Ubuntu 18.04.

Clone the repository with the official Oracle docker images:

git clone https://github.com/oracle/docker-images

Install docker, download Oracle Database, put it to the directory docker-images/OracleDatabase/SingleInstance/dockerfiles/18.3.0 containing the Dockerfile and run the following commands to build and run Enterprise Edition:

cd docker-images/OracleDatabase/SingleInstance/dockerfiles/18.3.0
mv ~/Downloads/LINUX.X64_180000_db_home.zip .
sudo docker build -t oracle/database:18.3.0 --build-arg DB_EDITION=EE .
sudo docker run -d -it --rm --name oracle18 oracle/database:18.3.0
sudo docker logs oracle18 --tail 100
sudo docker logs oracle18 | grep -i password

and the following commands to build and run Standard Edition 2:

sudo docker build -t oracle/database-se:18.3.0 --build-arg DB_EDITION=SE2 .
sudo docker run -d -it --rm --name oracle18se oracle/database-se:18.3.0
sudo docker logs oracle18se --tail 100

the first string of the docker output contains the generated password for SYS, SYSTEM and PDBADMIN.

SE2 run successfully with the following output:

...
SQL> Disconnected from Oracle Database 18c Standard Edition 2 Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
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-03-06T12:43:19.265419+00:00
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"
2019-03-06T12:43:20.130939+00:00
ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl' SCOPE=SPFILE;
2019-03-06T12:43:20.246414+00:00
ALTER SYSTEM SET local_listener='' SCOPE=BOTH;
   ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
Completed:    ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE

but EE did not:

Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j002_7205.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_1"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-05T22:10:19.761446+00:00
ORCLPDB1(3):Resize operation completed for file# 10, old size 368640K, new size 378880K
2019-03-05T23:00:25.853278+00:00
Resize operation completed for file# 3, old size 532480K, new size 542720K
2019-03-05T23:10:38.156367+00:00
Thread 1 cannot allocate new log, sequence 6
Private strand flush not complete
  Current log# 2 seq# 5 mem# 0: /opt/oracle/oradata/ORCLCDB/redo02.log
2019-03-05T23:10:41.874004+00:00
Thread 1 advanced to log sequence 6 (LGWR switch)
  Current log# 3 seq# 6 mem# 0: /opt/oracle/oradata/ORCLCDB/redo03.log
2019-03-05T23:10:51.390250+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_10009.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_21"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-05T23:20:39.908336+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_10329.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_41"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-05T23:30:39.472674+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_10637.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_61"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-05T23:40:41.078629+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_10949.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_81"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-05T23:50:40.722763+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_11262.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_101"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-06T00:00:32.803000+00:00
Resize operation completed for file# 3, old size 542720K, new size 552960K
2019-03-06T00:00:40.183488+00:00
TABLE SYS.WRI$_OPTSTAT_HISTHEAD_HISTORY: ADDED INTERVAL PARTITION SYS_P206 (43529) VALUES LESS THAN (TO_DATE(' 2019-03-07 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLE SYS.WRI$_OPTSTAT_HISTGRM_HISTORY: ADDED INTERVAL PARTITION SYS_P209 (43529) VALUES LESS THAN (TO_DATE(' 2019-03-07 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
2019-03-06T00:00:42.772175+00:00
ORCLPDB1(3):TABLE SYS.WRI$_OPTSTAT_HISTHEAD_HISTORY: ADDED INTERVAL PARTITION SYS_P221 (43529) VALUES LESS THAN (TO_DATE(' 2019-03-07 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
ORCLPDB1(3):TABLE SYS.WRI$_OPTSTAT_HISTGRM_HISTORY: ADDED INTERVAL PARTITION SYS_P224 (43529) VALUES LESS THAN (TO_DATE(' 2019-03-07 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
2019-03-06T00:01:07.201773+00:00
TABLE SYS.WRP$_REPORTS_TIME_BANDS: ADDED INTERVAL PARTITION SYS_P226 (3351) VALUES LESS THAN (TO_DATE(' 2019-03-06 01:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
2019-03-06T00:10:33.770372+00:00
ORCLPDB1(3):Resize operation completed for file# 10, old size 378880K, new size 389120K
2019-03-06T00:20:42.999194+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_12191.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_161"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-06T00:30:44.642076+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_12507.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_181"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-06T00:40:46.251515+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_12809.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_201"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-06T00:50:46.410284+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_13134.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_221"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-06T01:00:47.424357+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_13443.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_223"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-06T01:00:59.716008+00:00
TABLE SYS.WRP$_REPORTS: ADDED INTERVAL PARTITION SYS_P246 (3352) VALUES LESS THAN (TO_DATE(' 2019-03-07 01:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLE SYS.WRP$_REPORTS_DETAILS: ADDED INTERVAL PARTITION SYS_P247 (3352) VALUES LESS THAN (TO_DATE(' 2019-03-07 01:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
2019-03-06T01:20:39.834797+00:00
Resize operation completed for file# 3, old size 552960K, new size 563200K
2019-03-06T01:20:51.112500+00:00
Thread 1 advanced to log sequence 7 (LGWR switch)
  Current log# 1 seq# 7 mem# 0: /opt/oracle/oradata/ORCLCDB/redo01.log
2019-03-06T01:30:50.363286+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_14387.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_281"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-06T01:40:52.221743+00:00
Errors in file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_j000_14700.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_301"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 49538
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 881
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 21631
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 23763
ORA-06512: at "SYS.DBMS_STATS", line 49526
2019-03-06T02:00:00.136646+00:00
Closing scheduler window
Closing Resource Manager plan via scheduler window
Clearing Resource Manager CDB plan via parameter
ORCLPDB1(3):Closing scheduler window
ORCLPDB1(3):Closing Resource Manager plan via scheduler window
ORCLPDB1(3):Clearing Resource Manager plan via parameter
2019-03-06T06:01:03.619603+00:00
Resize operation completed for file# 3, old size 563200K, new size 573440K

Building and running Oracle Database 12.2.0.1 Standard Edition 2:

cd docker-images/OracleDatabase/SingleInstance/dockerfiles/12.2.0.1
mv ~/Downloads/linuxx64_12201_database.zip .
sudo docker build -t oracle/database-se:12.2.0.1 --build-arg DB_EDITION=SE2 .
sudo docker run -d -it --rm --name oracle12se oracle/database-se:12.2.0.1
sudo docker logs oracle12se --tail 100
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
2019-03-06T14:09:38.775086+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
2019-03-06T14:09:40.120128+00:00
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"
2019-03-06T14:09:41.201288+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

Checking if the oracle instance is started:

sudo docker inspect oracle12se | grep IPAddress
telnet 172.17.0.2 1521
telnet 172.17.0.2 5500

Binding the container ports to the host ports:

sudo docker run -d -it --rm --name oracle12se -p 1521:1521 -p 5500:5500 oracle/database-se:12.2.0.1
sudo docker run -d -it --rm --name oracle18se -p 1521:1521 -p 5500:5500 oracle/database-se:18.3.0

Connecting with Oracle SQL Developer:

Running sqlplus with CDB in the container:

sudo docker exec -it oracle18se /bin/bash
cd /opt/oracle/product/18c/dbhome_1/bin/
export ORACLE_SID=ORCLCDB
./sqlplus sys as sysdba

SID for the pluggable DB:

export ORACLE_SID=ORCLPDB1

Running sqlplus in the container with version 12c:

sudo docker exec -it oracle12se /bin/bash
/opt/oracle/product/12.2.0.1/dbhome_1/bin
export ORACLE_SID=ORCLCDB
./sqlplus sys as sysdba


Making the database to be persisted over container recreation by storing the database outside of the container:

sudo useradd -d /home/oracle -m --uid 54321 oracle
sudo su - oracle
mkdir oradata18
exit
sudo docker run -d -it --rm --name oracle18se -v /home/oracle/oradata18:/opt/oracle/oradata -p 1521:1521 -p 5500:5500 oracle/database-se:18.3.0
sudo docker logs oracle18se | head | grep -i password

Links:

Leave a Reply

Your email address will not be published. Required fields are marked *