Oracle 19c with Docker
Tags: database, docker
Published: 2021-01-09 21:08:27

Article Originally published on my Blog [here](https://pazikas.com/2020/12/28/oracle-database-with-docker/).

<!-- wp:paragraph -->
<p>Running an Oracle 19c database Docker container is a fairly simple task but I thought it would be useful to document the steps required for reference and to help others starting out on this path.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Firstly Oracle only has 12c available via Docker Hub they had some legal grievances with each other a few years ago which means Oracle no longer updates the Docker Hub images but instead stores them <a href="https://github.com/oracle/docker-images" target="_blank" rel="noreferrer noopener">here</a> on GitHub. Another note is while the information on GitHub is great you still need to download the Oracle Database install .zip files from Oracle's website yourself further if you plan on patching the Oracle database you will need to have a valid Oracle Support licence and login to MOS.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Firstly clone the Oracle Docker images to your local machine with git</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>git clone https://github.com/oracle/docker-images.git</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>After you have cloned the repo you will see there is a lot more avaliable than just Oracle Database images but for this article its all we are concerned with, move to the OracleDatabase folder, then the SingleInstance folder and finially the 19.3.0 directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>cd ~/docker-images/OracleDatabase/SingleInstance/19.3.0</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>With your downloaded Oracle Database install .zip copy in into your current 19.3.0 directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>cp $HOME/Downloads/LINUX.X64_193000_db_home.zip .</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you plan on patching this container in the future the defualt scripts remove some key directories within $ORACLE_HOME to reduce image size that will cause you to run into issues when trying to patch in the future, the fix is simple by defult we choose to install the "SLIM" option we just need to update the Dockerfile within the 19.3.0 directory to read false.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>ARG SLIMMING=false</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Move back to the parent directory and run buildDockerImage.sh with a -v to specify database version in this case 19.3.0 and -e to indicate we want to use enterprise edition.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>cd ~/docker-images/OracleDatabase/SingleInstance</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>./buildDockerImage.sh -v 19.3.0 -e</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Depending on the resources you have on your machine will depend how quickly the next part goes, I would say on average it will take 20-30min so go have coffee, you should come back to a Build Complete message. We have not successfully created an Oracle Database Enterprise Edition 19.3.0 Docker Image.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>To run the image use the following;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>docker run --name "oracle19.3" -p 1521:1521 -p 5500:5500 -e ORACLE_PDB=orapdb1 -e ORACLE_PWD=topsecretpass -e ORACLE_MEM=3000 -v /opt/oracle/oradata -d oracle/database:19.3.0-ee</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Where --name is the name of the docker image, ORACLE_PDB is the PDB name, ORACLE_PWD is the database password and ORACLE_MEM is the memory allocated to the DB. This first run of the docker image will go away and create the database so expect it to take some time during its first run.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You can use sqldeveloper to connect to your PDB or connect to sqlplus via docker by logging directly into the docker image as per below</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>docker exec -it oracle19.3 /bin/bash</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>ps -ef |grep pmon</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>. oraenv</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>sqlplus / as sysdba</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Useful Docker commands</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Stop Docker Image</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>docker container stop oracle19.3</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Start docker container</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>docker container start oracle19.3</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Show running Docker containers</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>docker ps</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>List All Docker Images</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>docker images</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Delete Docker Image</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>docker image rm "image_id_here"</code></p>
<!-- /wp:paragraph -->