Skip to main content

Run on Docker

This tutorial shows how you can get started with DB2Rest in less than 10 minutes on Docker.

Minimum System Requirements

  • Java 21
  • 4-8 GB RAM/Memory.

1. Install Docker

To download the Docker desktop browse to this link. This page then shows options to download Docker for Mac, Windows, and Linux. Please click on the link for your operating system (OS) to start the download. After the download is completed, follow the steps outlined here pertinent to your OS, to install and test the Docker desktop.

2. Run DB2Rest

Now launch a terminal window to run the DB2Rest docker image. DB2Rest docker image is available on Dockerhub. It is assumed that a MySQL server has already been installed, started, and populated with Sakila database objects and data. MySQL Community Edition (CE) is available for download here.

Now in the terminal window run the following command:

$ docker run -p 8080:8080 -e DB_URL=[DB URL] -e DB_USER=[User] -e DB_PASSWORD=[Password] kdhrubo/db2rest:latest
info

DB2Rest internally starts on port 8080 by default, but is not exposed automatically on startup. To expose the default service port 8080, use the -p option on docker run, such as -p 8080:8080 or an alternative port such as -p 1234:8080

Sl#Parameter NameDescriptionExample
1.DB URLJDBC URL conneciton string- MySQL : jdbc:mysql://host.docker.internal:3306/sakila
- PostgreSQL : jdbc:postgresql://host.docker.internal:5432/sakila?currentSchema=public
2.DB_USERDatabase user
3.DB_PASSWORDDatabase password

This will start DB2Rest within seconds ready to serve API requests on the MySQL database.