Bismillah...
Introduction
In this guide, we will cover how to run Oracle 21c on Docker and restore a backup from a dump file. This includes building a Docker image, running it as a container, and executing a backup restoration script.
Prerequisites
Ensure you have Docker installed on your system.
Step 1: Building the Docker Image
Create the following files:
Dockerfile:
FROM gvenzl/oracle-xe:21
# If you have a backup file
COPY start.sh /opt/oracle/start.sh
COPY data.sql /container-entrypoint-initdb.d/data.sql
RUN mkdir -p /opt/oracle/dbbackupdmp
COPY mydb.dmp /opt/oracle/dbbackupdmp/mydb.dmp
USER root
RUN chown oracle:oinstall /opt/oracle/dbbackupdmp/mydb.dmp
USER oracle
data.sql:
create user <user.name> IDENTIFIED BY <user.password>;
grant connect,resource,dba to <user.name>;
grant create session, grant any privilege to <user.name>;
grant unlimited tablespace to <user.name>;
create directory datapump as '/opt/oracle/dbbackupdmp';
grant read, write on directory datapump to <user.name>;
start.sh:
impdp <user.name>/<user.password> directory=datapump dumpfile=mydb.dmp logfile=mydb.log schemas=<user.1>,<user.2>
Build the Docker image using:
docker build -t my/oracle:21 .
Step 2: Running the Docker Container
Run the image as a Docker container:
docker run -d -p 1521:1521 -e ORACLE_PASSWORD=P@ssw0rd --name=myoracle21 my/oracle:21
Step 3: Restoring the Backup (Optional)
Access the running container:
docker exec -ti myoracle21 bash
Navigate to the /opt/oracle
directory and execute the restoration script:
bash start.sh
Conclusion
Following these steps, you should have Oracle 21c running in a Docker container with your backup data restored. This setup is efficient for testing and development environments.
Thank you.
Top comments (0)