If you are beginning your software development career using a Mac and are interested in using relational databases like MySQL/MariaDB, PostgreSQL, Microsoft SQL Server, Azure CosmosDB SQL, or Oracle Database, then this article is for you!

Now, in the past when I used to run Linux on my laptops, I'd just install each database directly into my environment. Sometimes, I'd face problems like dependency hell, conflicts, and missing native libraries, and would eventually end up running the databases in isolated VirtualBox VMs. In today's containerized world, this is in the past.

If you really want to make your developer life easier, get used to using Dockerand spinning up databases in containers. All of them.

Running RDBMS in containers may not be suited for production, but for development/testing environments, it is the perfect fit.

If you haven't already done it, make sure you install Homebrew and Cask — package managers for Mac OS. This will be useful not only for this article but pretty much for everything you will eventually install in the future.

Prerequisites

You will have to install Docker. And while Kitematic is optional, I recommend you download it, as well. It's easier to manage the containers in your system once you create them (start/stop/restart/delete).

$ brew cask install docker kitematic

Once you have Docker installed, make sure you have an account in the Docker Store — sign up here. That will be needed for some of the databases. Once you have your account, log in to it either in the UI or with docker login.

CLIs for Database Clients

To connect to a database, you will need a client — ideally, one that you can quickly use via the command-line/terminal. For each database below, you will find two instructions: one to install and start the database using Docker and one to install and connect to that database using a CLI.

Most databases provide Client CLI within the Docker image, but I find it extremely useful to have these clients installed so you can easily connect to databases running elsewhere, such as in the cloud, or remote in some server in your intranet. Plus, you can also automate stuff writing scripts.

(Not that you can't do these things with CLI inside Docker… it's just my preference.)

Getting Started

All four major databases provide Docker images these days. And I was closely involved in the build-up of the Docker image for the Oracle Database, gracefully put together by my friend Gerald Venzl. But the other databases provide very useful and well-assembled Docker images, too, and I am sure you will appreciate them all.

PostgreSQL

This image is provided and supported by the PostgreSQL Docker Community — basically, people at Docker and also folks who are involved in PostgreSQL development. I found this image to also be very straightforward and simple to use.

Azure CosmosDB

CosmosDB is an interesting Microsoft Azure service that allows developers to use different APIs to connect to the same datastore. For example, you can use CosmosDB as a drop-in replacement for MongoDB, or Cassandra. It also provides a SQL API. You just point an existing application previously developed for one of these databases on CosmosDB and it will just work (well, give or take). It also scales beautifully. Even Thomson Reuters is using it.

The easiest way to use CosmosDB is again, IMO, through the command line. But to play with it, of course, you will first need an Azure account. Besides giving a few hundreds of dollars for you to use in your first 30 days, Microsoft Azure also has many services that are always free (to certain limits/quotas) and some services that are free in your first 12 months if you activate your subscription during or after the first 30 days.

Oracle Database

During my time at Oracle, I led the company's presence on GitHub, helping teams structure their projects and launch newly open-sourced libraries, tools, resources, and sample sets. There was, though, one particular project I was taking care of since the beginning: the docker-images repository. And I am extremely proud of the advancements and improvements of developer experience for some key Oracle products that we were able to deliver thanks to Docker and the amazing work from folks like Monica Riccelli, Avi Miller, Gerald Venzl, and many other engineers and product managers.

In the past, it used to be quite frustrating to install and run Oracle Database for development purposes, but thanks to Gerald and Docker, it is now as simple as it can get.

Now, while anyone can go to the docker-images repository, download Dockerfiles, and build their own images for the commercial products, there are also some pre-built images available for common products on the Docker Store and also on the Oracle Container Registry server.

Below, I outline the steps required for downloading and running an Oracle Database image from the Docker Store.

At this point, I will assume you already have a Docker ID (account). If you don't, create one.

It may take a while, but it will work. Check the docker logs for progress.

In the old days, you'd probably connect to Oracle Database using SQL*PLus. In the 21st century, though, you may want to use SQLcl. This new tool is way more interactive in the terminal than SQL*Plus ever was. So, I highly recommend you to try it. Besides, it is designed by friends of mine at Oracle, namely Kris Rice and Jeff Smith.

To install SQLcl and connect to the image created above, do the following: