DEV Community

Thiago da Silva Adriano
Thiago da Silva Adriano

Posted on

12 2

ORACLE DATABASE IN DOCKER

In this article I'll show you how to install oracle database in a container docker

Create a Docker container with Oracle Database

To create a Docker Container with Oracle Database we need to log in at docker account. To do this, type this command bellow in your terminal:



docker login


Enter fullscreen mode Exit fullscreen mode

And put your registered login like this print bellow:

Image description

Now let's go to pull the docker image. To do this, just type this command bellow:



docker pull store/oracle/database-enterprise:12.2.0.1


Enter fullscreen mode Exit fullscreen mode

Create a container

Our next step will be to create a container, to do this, we just need this command bellow:



docker run -d -p 1521:1521 --name oracle store/oracle/database-enterprise:12.2.0.1


Enter fullscreen mode Exit fullscreen mode

This command will create a oracle database container with the name oracle using the version 12.2.0.1, working in port 1521:1521.

After the installation is completed, we can connect to the Oracle SQL Plus tool to create users and grant the necessary permissions as follows.



docker exec -it oracle bash -c "source /home/oracle/.bashrc; sqlplus /nolog"


Enter fullscreen mode Exit fullscreen mode

Now let's to connect as sysdba in Docker



connect sys as sysdba;


Enter fullscreen mode Exit fullscreen mode

And create your Oracle User:



create user your_username identified by your_password;


Enter fullscreen mode Exit fullscreen mode

After this grant permission to your new user:



GRANT ALL PRIVILEGES TO YOUR_USER_NAME;


Enter fullscreen mode Exit fullscreen mode

NOTE: You can grant permissions for certain privileges ​​such as SELECT, INSERT, UPDATE, CREATE TABLE instead of ALL PRIVILEGES, I granted all priviles just to show how you can do this in this article.

Now to connect to SQL Developer in Docker you can use this connetion bellow:



Username: username
Password: password
Hostname: localhost
Port: 1521
Service name: ORCLCDB.localdomain


Enter fullscreen mode Exit fullscreen mode

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

Top comments (1)

Collapse
 
loiclefevre profile image
Loïc

You'll love the slim images from Gerald Venzl (Oracle Database Product Manager)!

docker pull gvenzl/oracle-xe:21.3.0-slim

Check it here

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more