<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ronald Rosier]]></title><description><![CDATA[Developing applications for enterprises, mainly on the Microsoft technology stack.
Passionate about integration architectures and the full development lifecycle]]></description><link>https://www.ronaldrosier.net</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 19:56:03 GMT</lastBuildDate><atom:link href="https://www.ronaldrosier.net/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Run Oracle in a Docker container on Windows]]></title><description><![CDATA[This article goes through the steps of running a docker container with a development or free oracle database.
This is an alternative way from installing Oracle either local or hosting on a VM.
Prerequisite
Docker Desktop (check your license) configur...]]></description><link>https://www.ronaldrosier.net/run-oracle-in-a-docker-container-on-windows</link><guid isPermaLink="true">https://www.ronaldrosier.net/run-oracle-in-a-docker-container-on-windows</guid><category><![CDATA[Docker]]></category><category><![CDATA[Databases]]></category><category><![CDATA[Oracle]]></category><dc:creator><![CDATA[Ronald Rosier]]></dc:creator><pubDate>Sat, 07 Sep 2024 18:28:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1725722988708/06d76447-aaf0-421c-b570-6183271ed8af.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This article goes through the steps of running a docker container with a development or free oracle database.</p>
<p>This is an alternative way from installing Oracle either local or hosting on a VM.</p>
<h2 id="heading-prerequisite">Prerequisite</h2>
<p>Docker Desktop (check your license) configured to run <a target="_blank" href="https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-10-linux">Linux containers</a>.</p>
<h2 id="heading-pull-the-official-oracle-db-container-image">Pull the official Oracle DB container image</h2>
<p>Oracle provides pre-build Docker images hosted on their own registry at <a target="_blank" href="https://container-registry.oracle.com/">container-registry.oracle.com</a>.</p>
<p>You'll find a number of images under the Database containers.</p>
<p>For development I use either <strong>express</strong> or <strong>free</strong>. Both are falling under the Oracle Free Use Terms and Conditions.</p>
<p><img alt /></p>
<blockquote>
<p><em>Note: to access any software from oracle, you will need first to create a free Oracle account.</em></p>
</blockquote>
<pre><code class="lang-powershell">docker login container<span class="hljs-literal">-registry</span>.oracle.com

<span class="hljs-comment"># express</span>
docker pull container<span class="hljs-literal">-registry</span>.oracle.com/database/express:<span class="hljs-number">21.3</span>.<span class="hljs-number">0</span><span class="hljs-literal">-ex</span>

<span class="hljs-comment"># free</span>
docker pull container<span class="hljs-literal">-registry</span>.oracle.com/database/free:<span class="hljs-number">23.5</span>.<span class="hljs-number">0.0</span>
</code></pre>
<h2 id="heading-run-the-oracle-database-with-docker">Run the Oracle database with Docker</h2>
<p>We create a local directory which will contain the database data files. This will then be mounted to the container, ensuring data persistency between the containers lifecycle.</p>
<p>In my case, I create a local directory which matches the oracle version of my running container.</p>
<p>C:\oracle\data\21.1.3 (express)<br />C:\oracle\data\23.2 (free)</p>
<pre><code class="lang-powershell"><span class="hljs-comment"># express  </span>
docker run -<span class="hljs-literal">-name</span> oracle<span class="hljs-literal">-21</span>.<span class="hljs-number">1.3</span>.<span class="hljs-number">0</span><span class="hljs-literal">-xe</span> <span class="hljs-literal">-p</span> <span class="hljs-number">1521</span>:<span class="hljs-number">1521</span> <span class="hljs-literal">-e</span> ORACLE_PWD=PWD1234<span class="hljs-literal">-v</span> C:\oracle\data\<span class="hljs-number">21.1</span>.<span class="hljs-number">3</span>:/opt/oracle/oradata container<span class="hljs-literal">-registry</span>.oracle.com/database/express:<span class="hljs-number">21.3</span>.<span class="hljs-number">0</span><span class="hljs-literal">-xe</span>

<span class="hljs-comment">#free</span>
docker run -<span class="hljs-literal">-name</span> oracle<span class="hljs-literal">-23</span>.<span class="hljs-number">5.0</span>.<span class="hljs-number">0</span><span class="hljs-literal">-free</span> <span class="hljs-literal">-p</span> <span class="hljs-number">1521</span>:<span class="hljs-number">1521</span> <span class="hljs-literal">-e</span> ORACLE_PWD=PWD1234 <span class="hljs-literal">-v</span> C:\oracle\data\<span class="hljs-number">23.5</span>:/opt/oracle/oradata container<span class="hljs-literal">-registry</span>.oracle.com/database/free:<span class="hljs-number">23.5</span>.<span class="hljs-number">0.0</span>
</code></pre>
<p>You should see following in the output window.</p>
<pre><code class="lang-plaintext">2024-09-07 16:38:46 Starting Oracle Net Listener.
2024-09-07 16:38:48 Oracle Net Listener started.
2024-09-07 16:38:48 Starting Oracle Database instance XE.
2024-09-07 16:38:53 Oracle Database instance XE started.
2024-09-07 16:38:53
2024-09-07 16:38:53 The Oracle base remains unchanged with value /opt/oracle 
2024-09-07 16:38:53 #########################
2024-09-07 16:38:53 DATABASE IS READY TO USE!
2024-09-07 16:38:53 #########################
</code></pre>
<p>At this moment, you're able to connect to the database using sqlplus once you installed the client packages.</p>
<h2 id="heading-install-client-for-windows-64-bit">Install client for windows 64-bit</h2>
<p>To connect to your database with your application, you will need to install the Oracle client.</p>
<p>You can download the <a target="_blank" href="https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html#ic_winx64_inst">client packages here</a>. Follow the instructions under "<strong>Instant Client Installation for Microsoft Windows 64-bit</strong>".</p>
<p>For my tests, I installed following packages below. I used version 23.5.0.0.0 and could connect to both the free and express containers.</p>
<ul>
<li><p>Basic Light Package</p>
</li>
<li><p>SQL*Plus Package</p>
</li>
</ul>
<h2 id="heading-configure-tnsnamesora">Configure tnsnames.ora</h2>
<p>It is very common to configure a TNS name as a user-friendly alias for the database connection.</p>
<p>The docker database is a multitenant container database (CDB).<br />Read more about <a target="_blank" href="https://docs.oracle.com/en/database/oracle/oracle-database/19/multi/introduction-to-the-multitenant-architecture.html"><strong>multitenant architecture</strong></a>.</p>
<p>If your scripts or code do not support CDB, you will need to connect to the underlying PDB (Pluggable Database).</p>
<blockquote>
<p><em>Main issue with scripts and code could be creation of users.</em><br /><em>In CDB, you have the notion of Common and Local User.</em><br /><em>When connected to the root (CDB), the 'create user' command will create a common user which has a number of restrictions.</em><br /><em>For our scripts to work, we need to open a session on the PDB to create a local user only known to that PDB.</em><br /><a target="_blank" href="https://www.dbasolved.com/2013/06/common-user-vs-local-user-12c-edition/"><em>https://www.dbasolved.com/2013/06/common-user-vs-local-user-12c-edition/</em></a></p>
</blockquote>
<p>Create following <strong>tnsnames.ora</strong> file and save it under {oracle-client-root}/network/admin.</p>
<pre><code class="lang-text"># tnsnames.ora Network Configuration File: C:\oracle\client\instantclient_23_5\network\admin\tnsnames.ora

ALIAS =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    ) 
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XEPDB1) #FREEPDB1
    )
  )
</code></pre>
<p>You may want to set the TNS_ADMIN environment variable to this directory.</p>
<h2 id="heading-test-connection">Test connection</h2>
<h3 id="heading-sqlplus">SqlPlus</h3>
<p>Use sqlplus command line tool to connect to the database.</p>
<pre><code class="lang-powershell">sqlplus sys/PWD1234<span class="hljs-selector-tag">@</span>//localhost:<span class="hljs-number">1521</span>/XEPDB1 as sysdba
<span class="hljs-comment"># use tnsnames</span>
Sqlplus sys/@ALIAS as sysdba
</code></pre>
<h3 id="heading-sql-developer-extension-for-vs-code">SQL Developer extension for VS Code</h3>
<p>You can use a graphical interface with SQL Developer or the SQL Developer extension in VS Code.</p>
<p>Make sure you select connection type <strong>TNS</strong>, and specify the tnsnames.ora directory in the settings.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1725723525396/6f13b641-60b7-4258-b111-bddec8e9f5c1.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item></channel></rss>