Running Oracle in Docker for development and testing

Running Oracle in Docker for development and testing

I’m working on a Python based microservice that needs to communicate with an Oracle database. My development environment consist only of my laptop, so to do some real testing I decided to spin up Oracle in a Docker container on my laptop.

For me, the process of getting things up and running wasn’t very straight forward for an Oracle newbie as myself, so I though I’d share my setup in case others may benefit from it.

Let’s start with my docker-compose.development.yml file:

The Dockerfile.runtime file, which could benefit from a better name, has this content:

In my workflow, I start the database in a shell and leave it running:

To set up the initial database contents, I’ve created a very simple script something like this:

To run the script, I log into the Oracle server and run it like this:

Now, the database should be ready for requests. Let’s shift our focus over to the Python code that will communicate with the database. I’m using SQLAlchemy, and connect to the database with this very simple connection statement:

To start the service, we’ll issue another docker-compose command:

Leave a Reply

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

%d bloggers like this: