download and install from docker (macOS)
you will be prompted for your docker username and password by running this command
$ docker login
pull Oracle 12cR2 image by running the following command
$ docker pull store/oracle/database-enterprise:12.2.0.1
you need Oracle sqlplus and client to connect to the database, follow Steps 1 & 2 from the following guide:
how-to-install-oracle-sqlplus-and-oracle-client-in-mac-os
In Terminal
$ vi ~/.bash_profile
Some convenient vi commands
i to insert
:q! to exit without saving
:qw to save and exit
Add the following lines
export ORACLE_HOME=/Applications/oracle/product/instantclient_64/12.2.0.1
export PATH=$ORACLE_HOME/bin:$PATH
export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
save and exit vi
:qw
In Terminal
$ source ~/.bash_profile
over here I am giving my oracle container the name "myorcldb"
the following command will run a docker container with Oracle database
$ docker run -d -it --name myorcldb -P --restart always store/oracle/database-enterprise:12.2.0.1
wait for a few minutes and check that container status changes from “starting” to “healthy”
NOTE: make sure container is running everytime you reboot your machine
$ docker ps
$ docker run -d -it --name myorcldb -p [yourip]:[assignedip] --restart always store/oracle/database-enterprise:12.2.0.1
--restart always
will always make sure your Oracle docker container starts up when your machine is rebooted.
use docker ps to check that your container is "healthy" before you fire up your DBMS GUI.
You can stop or remove the container
$ docker stop [container id]
or
$ docker rm [container id]
we need port information so that our Oracle client can listen to the right port that the database has exposed,
run the following to check the port assigned
$ docker port myorcldb
since I was automatically assigned to port 32773, I will be using this port number for the next step.
A Oracle client uses a tnsnames file to look for connection strings.
in the following directory
/Applications/oracle/product/instantclient_64/12.2.0.1/network/admin
create a tnsnames.ora text file, this file is used by the Oracle client to connect to the database
$ vi /Applications/oracle/product/instantclient_64/12.2.0.1/network/admin/tnsnames.ora
copy the contents below into the vi editor
from the "check ports" step we also noticed the ip address was 0.0.0.0 i.e. localhost, hence we will use
localhost in the connection details
Contents of your tnsnames.ora file
ORCLPDB1=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=localhost)(PORT=1521))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCLPDB1.localdomain)))
and you're all set to start using your database!
Oracle DBMS
Key in the following login credentials on your DBMS GUI
in sqldeveloper you can key in the following credientials on clicking "New connection"
test the connection before saving
Connection name:
username: system
password: Oradoc_db1
hostname: localhost
port: 1521
service name: ORCLPDB1.localdomain
Since I personally like using DBeaver
you may download it from dbeaver website
the credientials are similar but in different fields
test the connection before saving
Host: localhost
Port: 1521
Database: ORCLPDB1.localdomain [Service name]
username: system
password: Oradoc_db1
your database comes clean with no users created, you can create a user account for your specific needs
with the following command by running the below in the DBMS GUI as SYSTEM admin
CREATE USER student IDENTIFIED BY studentpassword;
GRANT ALL PRIVILEGES TO student;
DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;
DBeaver
Host: localhost
Port: 1521
Database: ORCLPDB1.localdomain [Service name]
username: student
password: studentpassword
since the docker container is running backend, stopping the docker container will stop the database service but your data will not be lost. you will lose your database if you remove the docker container. do not remove the docker container! If you do so you will have to restart the setup process again. if you dislike using the --restart always argument in the docker run ... store/oracle/database-enterprise:12.2.0.1 command as shown above, you would have to manual start the docker container everytime daemon or your machine is rebooted by typing docker start [container name].
run-oracle-database-in-docker-using-prebaked-image-from-oracle-container-registry-a-two-minute-guide