Oracle Database Free with Docker

In this article, we will identify the type of free Oracle Database image we need, deploy it, connect to it, and create a database user, with the goal of making this instance useful for the development environment.

Tags

Select the pull command based on your PC or VPS/server architecture:

TagOS / ArchitectureSizePull command
23.5.0.0-lite-arm64linux/arm64836.74 MBdocker pull container-registry.oracle.com/database/free:23.5.0.0-lite-arm64
23.5.0.0-arm64linux/arm642.94 GBdocker pull container-registry.oracle.com/database/free:23.5.0.0-arm64
23.5.0.0-lite-amd64linux/amd64859.78 MBdocker pull container-registry.oracle.com/database/free:23.5.0.0-lite-amd64
23.5.0.0-amd64linux/amd642.99 GBdocker pull container-registry.oracle.com/database/free:23.5.0.0-amd64

The official and up-to-date list of tags can be found on the Oracle website.

Deploy Oracle Database Free with Docker

1. Download the image

Select the pull command from the previous section called “Tags” and run it in the terminal. For example:

docker pull container-registry.oracle.com/database/free:23.5.0.0-lite-amd64

2. Create a volume

Execute the following command in the terminal to create a volume:

docker volume create <volume name>

Example command:

docker volume create sandbox-oracledb-data

3. Run the container

Command:

docker run -d --name <oracledb container name> \
-p <host port>:1521 \
-e ORACLE_PWD=<your password> \
-e ORACLE_CHARACTERSET=AL32UTF8 \
-e ORACLE_PDB=<your database name> \
-v <your volume name>:/opt/oracle/oradata \
container-registry.oracle.com/database/free:<tag>

Example, considering the previously downloaded image and created volume:

docker run -d --name sandbox-oracledb \
-p 1521:1521 \
-e ORACLE_PWD=changeme \
-e ORACLE_CHARACTERSET=AL32UTF8 \
-e ORACLE_PDB=sandboxpdb \
-v sandbox-oracledb-data:/opt/oracle/oradata \
container-registry.oracle.com/database/free:23.5.0.0-lite-amd64

Connect from SQL Developer or any compatible database management tool

  • Host: IP
  • Puerto: 1521
  • Database: Value of the environment variable ORACLE_PDB. Also select the Service Name option.
  • User: system
  • Password: Value of the environment variable ORACLE_PWD.
  • Authentication: Oracle Database Native
  • Role: Normal

If you deployed the database on a server or VPS, make sure the port is open or is not blocked by any firewall.

Create New User

1. Define a naming standard

For example, suppose a system manages two applications (Sales and Purchases) and two environments (development and production). The naming convention could be as shown in the following table:

SchemaDescripción
APP_SALES_DEVDevelopment schema for the Sales application
APP_SALES_PRODProduction schema for the Sales application
APP_PURCHASES_DEVDevelopment schema for the Purchases application
APP_PURCHASES_PRODProduction schema for the Purchases application

2. Create user using the following SQL commands

SQL commands:

CREATE USER <SCHEMA_AND_USER_NAME> IDENTIFIED BY "<PASSWORD>";
GRANT CONNECT, RESOURCE TO <SCHEMA_AND_USER_NAME>;
GRANT CREATE SESSION TO <SCHEMA_AND_USER_NAME>;
GRANT UNLIMITED TABLESPACE TO <SCHEMA_AND_USER_NAME>;

Example:

CREATE USER APP_SANDBOX_DEV IDENTIFIED BY "changeme";
GRANT CONNECT, RESOURCE TO APP_SANDBOX_DEV;
GRANT CREATE SESSION TO APP_SANDBOX_DEV;
GRANT UNLIMITED TABLESPACE TO APP_SANDBOX_DEV;

References