Install Oracle database on Docker

There is often a need to work with the Oracle database. There are many ways to install this database. However, those who have deployed Oracle out of the box, know what a tambourine dance is and probably studied more than one ritual. There are several off-the-shelf solutions from Sun Microsystems now, for those who are not suited to Oracle VM VirtualBox they provide the option of using an Oracle Database Enterprise Edition image on Docker Hub. One of the benefits of using Docker is quick and easy preparation. I wanted to try and get the Oracle Database Enterprise Edition up and running quickly for use in a development environment.

Used:

Docker Oracle Database EE Mac OS

It is necessary to execute:
– Installing Docker on MacOs;
– Deploying an Oracle image on Docker;
– Create Database/Tables/Test Records;
– Establish a connection to the database;

First, you need to create account at Docker Hub

Download app: Docker Desktop

Login via terninal. The first time you log in, you need to enter your Docker Hub account username and password.

docker login

View running containers

docker ps

Next, you need to download Oracle Database Enterprise Edition image from Docker Hub. Fill in all the fields.

docker pull store/oracle/database-enterprise:12.2.0.1

Run the container based on the downloaded Oracle image:

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

The exec command only works for running containers and is used to execute commands inside Docker containers, establish a connection.

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

Let’s connect to the database and create a user:

CONNECT sys AS sysdba;
-- password as 'Oradoc_db1'
ALTER SESSION SET "_ORACLE_SCRIPT"=TRUE;
CREATE USER gotoqa IDENTIFIED BY gotoqa;
GRANT ALL PRIVILEGES TO gotoqa;

Now you can connect to our created database:

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

It ended up taking about 15 minutes to start Oracle Database in a Docker container out of the box. In my opinion, really the fastest way to get started with Oracle DB.

Releated Post