Docker Engine is available on a variety of Linux platforms, macOS and Windows 10 through Docker Desktop, and as a static binary installation. Install Docker at system according to your platform.
Oracle database images are not available on Docker hub nowadays. These images can be only accessed from Oracle Docker registry (https://container-registry.oracle.com).
To create account for Oracle Docker Registry visit https://profile.oracle.com/myprofile/account/create-account.jspx and complete your registration.
Post registration login to Oracle account with your registered credentials at https://container-registry.oracle.com/
Once you logged in at https://container-registry.oracle.com/ search with keyword “database“. Select image which you want to pull, accept Oracle’s terms and conditions provided for that image, without accepting it you will not be able to pull the image.
To login at Oracle Registry with Docker you can specify the registry server name for Oracle.
docker login container-registry.oracle.com
Specify version which you wish to pull OR pull latest version. Use following command(s) for pulling image.
docker pull container-registry.oracle.com/database/enterprise:21.3.0.0 ## OR docker pull container-registry.oracle.com/database/enterprise:latest
Image will be pulled without any error messages at screen. If you got an error message(s) saying the image does not exist OR you don’t have the right, then you need to accept Oracle’s terms and conditions for that image.
Run following command to create an Oracle database container
docker run -dit -p 1521:1521 --name oracle_db container-registry.oracle.com/database/enterprise:21.3.0.0 ## OR docker run -dit -p 1521:1521 --name oracle_db container-registry.oracle.com/database/enterprise:latest
The container may take a few minutes to fully boot, you can view it’s status by using log command
docker logs -f oracle_db
When you see logged message “Database is ready for use“, it means that the container now ready for use.
Use exec command into the container for accessing database for some management tasks.
docker exec -it oracle_db bash -c "source /home/oracle/.bashrc; sqlplus /nolog"
You are now ready to execute commands.
At docker container SQL command line create a user so you can use that to connect to the database later using client application.
connect sys as sysdba;
When prompted to enter password, enter Oradoc_db1
Execute following commands one by one.
alter session set "_ORACLE_SCRIPT"=true; create user nishant identified by secret_here; GRANT ALL PRIVILEGES TO nishant;
With above commands, user called nishant has been created with password secret_here.