DEV Community

Ricardo
Ricardo

Posted on • Originally published at rmauro.dev on

Oracle Database on Docker for Development

Oracle Database on Docker for Development

Setting up Oracle Database for development in docker is very easy - it also runs in WSL2.

Let's use the oracleinanutshell/oracle-xe-11g image. https://hub.docker.com/r/oracleinanutshell/oracle-xe-11g

Running Oracle Database on Docker

Run the following commands in your terminal.

#pulls the images from docker hub
docker pull oracleinanutshell/oracle-xe-11g

#runs the image using port forwarding 
docker run -d -p 49161:1521 oracleinanutshell/oracle-xe-11g
Enter fullscreen mode Exit fullscreen mode

Pull and Run Oracle XE 11g

The output should be something like this.

Oracle Database on Docker for Development

Set up a new user and configure the tablespace

With the Application running in the background let's create a new Oracle User and set up the appropriate tablespace and grants.

Get the running container Id and attach it running bash.

docker exec -it 82 bash
Enter fullscreen mode Exit fullscreen mode

Type sqlplus to open SQLPlus in the terminal.

sqlplus
Enter fullscreen mode Exit fullscreen mode

Connect using the username and password below.

Database Information

hostname: localhost
internal port: 49161
sid: xe
username: system
password: oracle
Enter fullscreen mode Exit fullscreen mode

Oracle Database on Docker for Development
Connected at SQLPlus

Run the following commands to set up the new user and tablespace.

CREATE TABLESPACE TSD_USERDB LOGGING DATAFILE 'TSD_USERDB.DBF' SIZE 200M AUTOEXTEND ON NEXT 200M MAXSIZE 400M;

CREATE TABLESPACE TSI_USERDB LOGGING DATAFILE 'TSI_USERDB.DBF' SIZE 200M AUTOEXTEND ON NEXT 50M MAXSIZE 400M;

CREATE USER USERDB IDENTIFIED BY PASSWORD DEFAULT TABLESPACE TSI_USERDB QUOTA UNLIMITED ON TSD_USERDB QUOTA UNLIMITED ON TSI_USERDB;
Enter fullscreen mode Exit fullscreen mode

Setup tablespace

Then run the necessary grants.

GRANT CREATE SESSION TO USERDB;
GRANT CREATE PROCEDURE TO USERDB;
GRANT CREATE VIEW TO USERDB;
GRANT CREATE TABLE TO USERDB;
GRANT CREATE SEQUENCE TO USERDB;
GRANT CREATE TRIGGER TO USERDB;
Enter fullscreen mode Exit fullscreen mode

Setup permissions

Connect using SQL Developer

Connect using the recently created user to manage your database.

Database Information

hostname: localhost
port: 49161
sid: xe
username: USERDB
password: PASSWORD
Enter fullscreen mode Exit fullscreen mode

Oracle Database on Docker for Development

All done here. If you like it subscribe for more content.

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.