Install Oracle database on Docker

Working with the Oracle database often requires careful installation and configuration. Deploying Oracle out of the box can be a complex process, requiring extensive knowledge and following specific procedures. However, there are convenient solutions available, such as the Oracle Database Enterprise Edition image on Docker Hub provided by Sun Microsystems.

Using Docker for Oracle Database offers several benefits, including quick and easy setup, making it ideal for development environments. With Docker, you can swiftly prepare and run the Oracle Database Enterprise Edition, allowing you to start working with it without the hassle of traditional installation methods.

By leveraging Docker and the pre-configured Oracle Database image, you can streamline the process and focus on your development tasks more efficiently.

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

To log in to Docker Hub via the terminal, follow these steps:

  1. Open a terminal window.
  2. Run the command: docker login This command will prompt you to enter your Docker Hub account username and password.
  3. Enter your Docker Hub account username and press Enter.
  4. Enter your Docker Hub account password and press Enter. Note: When you type your password, no characters will be displayed for security reasons. Just type it and press Enter.
  5. If the login is successful, you will see a message confirming your login.

You are now logged in to Docker Hub via the terminal and can proceed with the remaining steps.

docker login

View running containers

docker ps

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

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 took approximately 15 minutes to start Oracle Database in a Docker container, providing a quick and efficient way to get started with Oracle DB. In my opinion, this is the fastest way to begin working with Oracle DB.

Related Posts