Grabbing a coffee? Install Db2 while you’re away

Installing Db2 on your coffee break

How to install Db2 11.5 on Windows, MacOS or Linux with a single command, in less than 5 minutes

Today IBM released Db2 11.5. While the release is stacked with new functionality, my single favorite feature is the dramatically improved install experience — it’s now possible to install Db2 on Mac, Linux or Windows with a single command, in less than 5 minutes. To put that another way, if you’re about to grab a coffee, start the install now and it’ll be ready by the time you get back.

A short aside — These instructions assume you have Docker installed on your machine. If you haven’t yet installed Docker, you can install it here: Mac, Windows, CentOS, Debian, Fedora, Ubuntu.

This is the single command you’ll need to run to install Db2:

docker run -itd --name db2 --restart unless-stopped -e DBNAME=testdb -v ~/:/database -e DB2INST1_PASSWORD=GD1OJfLGG64HV2dtwK -e LICENSE=accept -p 50000:50000 --privileged=true ibmcom/db2

To break that down a bit, the command will pull the most recent version of the ibmcom/db2 container, name itdb2, and:

UPDATE: I’ve added --restart unless-stopped to the command above so that on reboot, or docker restart, the container is restarted. If you don’t want this behaviour, feel free to remove that option.

Here’s what it looks like when I run it:

That’s it! And complete in less than 5 minutes.

Of course, behind the scenes, there’s a lot going on. Once the container is pulled, the license is applied, the database is created, and it’s configured for optimal use. You can follow along with what’s going on after the install using the command:

docker logs db2

Once you see this in the logs, your installation is complete:

(*) Setup has completed.

Once the install has completed you can get into the container to run the Db2 CLP using the following command:

docker exec -it db2 bash -c "su - db2inst1"

Of course, once inside the container, you can run all of your favourite Db2 commands:

Happy Db2ing!

Adam has been developing and designing complex software systems for the last two decades. He is also a son, brother, husband and father.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store