The Developer’s Grimoire: Enchanting Oracle and PostgreSQL with Docker

Oracle and PostgreSQL in Docker

In the world of software development, managing databases can be like facing big challenges. Oracle and PostgreSQL are two powerful tools for handling data. But they can be difficult for many developers to master. That’s where Docker comes in. Docker is a special platform that makes dealing with Oracle and PostgreSQL easier. It’s like magic that makes big tasks smaller.

Docker’s Magic

Docker is like magic for organizing and controlling Oracle and PostgreSQL databases. It creates special containers that keep these databases separate from everything else, ensuring that they work consistently across different stages like development, testing, and production. This prevents the common problem of something working on one person’s computer but not on another’s. These containers are lightweight, so you can run multiple databases on one machine without slowing it down. Docker also makes setting up, updating, and working together on databases much easier, giving developers more flexibility and speed.

Managing Oracle Database in Docker

Exploring Oracle Database, which is a powerful system for managing data, needs a bit more careful attention because of its complex licensing rules.

    • Step 1: Install Docker

First, ensure that Docker is installed on your system. You can download Docker Desktop for your operating system from the official Docker website (https://www.docker.com/products/docker-desktop).

    • Step 2: Clone the Oracle Docker Images GitHub Repository
    •  Oracle provides a GitHub repository with Dockerfiles and scripts to build Docker  images for Oracle Database. Clone this repository to your local machine:

git clone https://github.com/oracle/docker-images.git

    • Step 3: Build the Oracle Database Docker Image

Navigate to the Oracle Database directory in the cloned repository and build the Docker image (replace xx with the version you want to build):

Here we are using 19.3.0 -e

cd docker-images/OracleDatabase/SingleInstance/dockerfiles

./buildContainerImage.sh -v 19.3.0 -e

Success depends on getting the right database version. For example, you need to download LINUX.X64_193000_db_home.zip from this website: (https://www.oracle.com/database/technologies/oracle19c-linux-downloads.html)

After you download it, put the file in the folder named 19.3.0.

    • Step 4: Run the Oracle Database Container

After building the image, run the container:

docker run -d –name oracle -p 1521:1521 -p 5500:5500 oracle/database:19.3.0-ee

This command orchestrates the deployment of an Oracle database container, named ‘oracle’, with ports 1521 and 5500 mapped for external access. It utilizes the image ‘oracle/database’ tagged as ‘19.3.0-ee’ in detached mode (-d), ensuring continuous operation in the background.

    • Step 5: Connect to the Database

Once the container is running, you can connect to the Oracle Database using the default system/admin accounts provided in the container’s documentation.

Setting Up PostgreSQL in Docker

Step 1: Pull the PostgreSQL Docker Image

First, you’ll need to pull the official PostgreSQL image from Docker Hub. Open your terminal and run:

docker pull postgres

Step 2: Run the PostgreSQL Container

Next, run the container with the following command:

docker run –name postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

To establish a PostgreSQL instance via Docker, the following command is tailored with essential parameters to ensure seamless setup and operation.

docker run –name postgres -e POSTGRES_USER=myusername -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -v /data:/var/lib/postgresql/data -d postgres

In the command given above,

The Docker container named postgres is configured with parameters -e POSTGRES_USER to set a distinct username, -e POSTGRES_PASSWORD to define the database password, and  -p 5432:5432 to link the host and container ports, facilitating seamless communication. Using the -v parameter, Postgres data is synchronized with a local folder, ensuring data persistence even if the container is terminated. Finally, running in detached mode -d, the Postgres Docker container operates in the background, providing uninterrupted service regardless of the command prompt’s status. The Docker image Postgres was previously downloaded to instantiate this container.

Step 3: Connect to the Database

You can connect to the database using any PostgreSQL client with the following details:

Host: localhost (or Docker machine IP if using Docker Toolbox)

Port: 5432 (default)

User: postgres

Password: mysecretpassword

Best Ways to Manage Databases in Docker

    • Keep Data Safe: Use Docker volumes to store your database data securely. If you don’t, your data will disappear when the container stops.
    • Stay Protected: Change default settings and add extra security measures to protect your databases from hackers.
    • Use Resources Wisely: Keep an eye on your system’s resources like CPU and memory to make sure your containers run smoothly.
    • Backup Regularly: Make regular backups to keep your data safe in case something unexpected happens.

Conclusion

Learning how to use Oracle and PostgreSQL in Docker makes database management simpler and takes your development journey to legendary levels. By following the steps and tips mentioned earlier, developers can easily handle the complexities of these big databases, focusing more on creating rather than managing. Docker isn’t just a tool; it’s like a trusted friend that helps you through software development smoothly and effectively.

As technology grows, Docker remains crucial for developers seeking efficiency, consistency, and teamwork. Whether dealing with Oracle or PostgreSQL, Docker provides the magic needed to succeed confidently.

Unleash the magic of Docker with Newt Global DMAP!

Ready to enchant your Oracle and PostgreSQL databases within Docker’s mystical realms?

Let Newt Global DMAP be your spellbook, guiding you through the arcane arts of database management and development.

Contact us at marketing@newtglobalcorp.com to discover how Newt Global DMAP can streamline your Docker-based database endeavors. Don’t miss this opportunity to elevate your development saga to mythic proportions.

Newt Global’s DMAP is a world-class product enabling mass migration of Oracle Db to cloud-native PostgreSQL – Faster, better, and cheaper.

Harness the power of Docker and Newt Global DMAP to unleash your full potential in the digital cosmos. Let’s embark on this magical journey together!