Skip to content

Instantly share code, notes, and snippets.

@thesuhu
Last active December 16, 2021 07:42
Show Gist options
  • Save thesuhu/6a0f89d19edb8b9c6abe40dfd6f9fb97 to your computer and use it in GitHub Desktop.
Save thesuhu/6a0f89d19edb8b9c6abe40dfd6f9fb97 to your computer and use it in GitHub Desktop.
Build Oracle 18c XE Docker images

Build Oracle 18c XE Docker image

# Written by The Suhu (2021).

# Tested on Ubuntu Server 20.04
# Make sure you have enough disk space

Build image

Clone Official source for Docker configurations, images, and examples of Dockerfiles etc.

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

Create user:

sudo useradd -d /home/oracle -m --uid 54321 oracle
sudo su - oracle
mkdir oradata

Change directory

cd docker-images/OracleDatabase/SingleInstance/dockerfiles

Build image and wait for it to finish

./buildContainerImage.sh -v 18.4.0 -x

Done, there should be oracle/database:18.4.0-xe image from the build

docker images

Problems that may occur when building an image

This Oracle installer is very large in size. And this version of Oracle XE requires a direct download from the internet. So, failed to download when build image may happen. I've tried to use Oracle installer from local file during image build, but failed. To solve this problem can be done with the following steps:

  1. Download Oracle 18 XE at https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm
  2. Create your own web server and and put the installer on your web server
  3. Edit docker-images/OracleDatabase/SingleInstance/dockerfiles/18.4.0/Dockerfile.xe. Replace INSTALL_FILE_1="https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm" with INSTALL_FILE_1="http://yourlocalwebserver/oracle-database-xe-18c-1.0-1.x86_64.rpm"

Another problem that may occur is when pull oraclelinux:7-slim. To solve this problem, you can pull the image before build.

docker pull oraclelinux:7-slim

Create container

docker run --name <container name> \
-p <host port>:1521 -p <host port>:5500 \
-e ORACLE_PWD=<your database passwords> \
-e ORACLE_CHARACTERSET=<your character set> \
-v <host mount point>:/opt/oracle/oradata \
oracle/database:18.4.0-xe

Example:

docker run -d --name oracle18xe \
-p 1521:1521 -p 5500:5500 \
-e ORACLE_PWD=yourpassword \
-v /home/oracle/oradata:/opt/oracle/oradata \
oracle/database:18.4.0-xe

Problems that may occur after running container

if logged in container and can't login as SYS, the error message that appears is ORA-12547: TNS:lost contact. Do the following steps to solve the problem:

  1. Type id and then press Enter to check user level
  2. Type ps -ef then press Enter to check which Oracle process is running on what user
  3. If it's running on oracle user, type su oracle then press Enter
  4. Finally, re-login SYS as SYSDBA and it should work

...

That's all and if you find it useful please star (:star:) & share.

@hendisantika
Copy link

I'm using Oracle 19c. But error

Command:

docker run -d --name oracle19c \
-p 1521:1521 -p 5500:5500 \
-e ORACLE_PWD=oracle19c \
-v /Users/hendisantika/Docker/oradata:/opt/oracle/scripts/setup \
oracle/database:19.3.0-ee

ORACLE EDITION: ENTERPRISE
/opt/oracle/product/19c/dbhome_1/bin/dbca: line 135: /u01/app/oracle/product/19.0.0/dbhome_1/bin/platform_common: No such file or directory
cat: /opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log: No such file or directory
cat: /opt/oracle/cfgtoollogs/dbca/ORCLCDB.log: No such file or directory

Any suggestion?

@thesuhu
Copy link
Author

thesuhu commented Oct 31, 2021

Sorry, I haven't tried to build the 19c version. But maybe this discussion link helps oracle/docker-images#1257 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment