DEV Community

Sharafat
Sharafat

Posted on

1

Setting up oracle database in Linux (podman container + vscode)

Installation

Mainly I will be focusing linux, but will work on mac as well with same commands.

For windows? You can download the installer from the official website and follow the instructions.

Setup a container

Docker and podman are the two most popular containerization tools. I will be using podman for this, and I will recommend podman as well. Why? Maybe I will write a blog on this later.

Whatever, let's install podman! You can follow the official documentation for this. I guess most of the major linux distributions have podman in their official repositories.

Like, for Arch Linux:

sudo pacman -S podman
Enter fullscreen mode Exit fullscreen mode

Pull the image

There are mainly two images available for free, full and lite.

To get the full image:

podman pull container-registry.oracle.com/database/free:latest
Enter fullscreen mode Exit fullscreen mode

And to be honest, it's a huge image around 9.48 G. So, I will recommend the lite version. It may take upto 2 G.

podman pull container-registry.oracle.com/database/free:23.5.0.0-lite
Enter fullscreen mode Exit fullscreen mode

Run the container

Now let's go ahead and actually run the container.

podman run -d -p 1521:1521 --name oracle-db container-registry.oracle.com/database/free:23.5.0.0-lite
Enter fullscreen mode Exit fullscreen mode

Here, I have used the lite version of the image. You can use the full version as well. Just replace the image name.
And the port 1521 is the default port for Oracle Database. You can change it if you want.

Flag -d is used to run the container in the background.
Flag -p is used to map the host port to the container port.
Flag --name is used to give a name to the container. (Try to remember it!)

Set a password

Here I have used 1234 as the password. You can use whatever you want.

podman exec -it oracle-db ./setPassword.sh 1234
Enter fullscreen mode Exit fullscreen mode

Connect to the database

You can use any database client to connect to the database. I will be using SQL*Plus.

podman exec -it oracle-db sqlplus
Enter fullscreen mode Exit fullscreen mode

And then enter the following details:

  • Username: system
  • Password: 1234 (Or the one you set in the previous step!)

Stop the container

podman stop oracle-db
Enter fullscreen mode Exit fullscreen mode

Start the container

podman start oracle-db
Enter fullscreen mode Exit fullscreen mode

You may need to start the container if you have restarted your system!

Misc

Port address

To get your outgoing forwarded port from podman, use the following,

podman port oracle-db     
Enter fullscreen mode Exit fullscreen mode

Integration

VSCODE

It would be weird if we have to use terminal everytime we want to access our database, right?
Let's use vscode. Simply install the following extension,

Or, Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.

ext install Oracle.sql-developer

The size of this extension is more than 300 M, so it'll take a bit of time.

  • Now on our left/ right toolbar, you will find a icon, and maybe try to add a new connection? You will asked to fill up a form.

  • For the port number try to use the one you got from podman port oracle-db.

  • For the username, use system.

  • And for the password, use the one you set in the previous steps.

  • For the service name, it should be FREE. Or you can use the following code in sqlplus to get the service name,

SELECT VALUE 
FROM V$PARAMETER 
WHERE NAME = 'service_names';
Enter fullscreen mode Exit fullscreen mode

And you are good to go!

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

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