DEV Community

Cover image for ๐Ÿš€ Easily Run Oracle Database in Docker
francotel
francotel

Posted on

1

๐Ÿš€ Easily Run Oracle Database in Docker

Why Oracle Database? ๐ŸŒ

Oracle is trusted for its reliability, scalability, and security. It supports:

  • Large-scale data processing
  • Advanced analytics
  • Integration with modern apps

Whether youโ€™re learning SQL, testing your app, or exploring databases, Oracle is a great choice.

oracle-db


Prerequisites โšก

  1. Install Docker Desktop:

    Make sure you have Docker Desktop installed on your macOS. Follow Dockerโ€™s official guide if needed.

  2. Docker Hub Account:

    Sign up for a free Docker Hub account to access Oracle images.


Letโ€™s Get Started ๐Ÿš€

Step 1: Pull the Oracle Container Registry ๐Ÿณ

1. Create an Oracle Account ๐Ÿ“

2. Log In to Oracle Container Registry ๐Ÿ”’

  • Visit Oracle Container Registry and log in with your new account.
  • Search for Oracle Database XE.
  • Accept the license terms. โœ…

3. Log In with Docker ๐Ÿณ

  • Open your terminal and run:
  docker login container-registry.oracle.com
Enter fullscreen mode Exit fullscreen mode

To download the Oracle Database Express Edition (XE), run:

docker pull container-registry.oracle.com/database/express:latest
Enter fullscreen mode Exit fullscreen mode

oracle-web

Step 2: Create and Run a Container ๐Ÿ 

If you want to persist your data, letโ€™s use a docker-compose.yml file to manage the container. Create a file named docker-compose.yml and add the following content:

version: '3.8'
services:
  oracle-db:
    image: container-registry.oracle.com/database/express:latest
    container_name: oracle-demo
    ports:
      - "1521:1521"
    environment:
      - ORACLE_PWD=YourPassword123
    volumes:
      - oracle-data:/opt/oracle/oradata # Path for persistent data
volumes:
  oracle-data:
Enter fullscreen mode Exit fullscreen mode

Now, start the container using:

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

This setup ensures that your database data will persist even if the container stops or is removed.

Step 3: Evaluate Security with Open Source Tools ๐Ÿ”’

To ensure your Docker setup is secure, you can use tools like Trivy and Hadolint:

What is Trivy?

Trivy is a comprehensive security scanner for container images. It helps identify vulnerabilities, misconfigurations, and exposed secrets within your Docker images.

trivy

Install Trivy:

brew install trivy
Enter fullscreen mode Exit fullscreen mode

Scan your Docker image for vulnerabilities:

trivy image container-registry.oracle.com/database/express:latest
Enter fullscreen mode Exit fullscreen mode

report-trivy

Alternative Security Tools Ranking:

  • Snyk: A developer-friendly tool to scan for vulnerabilities in Docker images and fix them.
  • Anchore: A detailed analysis tool that checks compliance and vulnerabilities.
  • Clair: A container vulnerability analysis service.
  • Dockle: A container linter that focuses on CIS Docker benchmarks.
  • Checkov: Ideal for scanning configuration files for security misconfigurations.

These tools offer various functionalities that cater to different aspects of container security. Choose the one that best fits your project needs.

Step 4: Connect to the Database ๐Ÿ”

Use SQL Developer or any SQL editor to connect:

Host: localhost
Port: 1521
Username: system
Password: YourPassword123
SID: xe
Enter fullscreen mode Exit fullscreen mode

select-client

connection

test-query

Once connected, you can start exploring Oracle SQL commands! ๐Ÿ’ก

Conclusion ๐ŸŽฎ

Running Oracle Database in Docker is simple and quick. Itโ€™s a fantastic way to:

  • Learn Oracle SQL.
  • Test applications locally.
  • Explore database management features.

๐Ÿค Let's Connect!

If you find this repository useful and want to see more content like this, follow me on LinkedIn to stay updated on more projects and resources!

LinkedIn

If youโ€™d like to support my work, you can buy me a coffee. Thank you for your support!

BuyMeACoffee

Thank you for reading! ๐Ÿ˜Š

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Sentry image

See why 4M developers consider Sentry, โ€œnot bad.โ€

Fixing code doesnโ€™t have to be the worst part of your day. Learn how Sentry can help.

Learn more

๐Ÿ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay