Docker images are available at the Oracle Container registry. See the Oracle Container registry at https://container-registry.oracle.com . I had never worked with Docker before, so I thought I would give it a try. Getting an Oracle Database up and running was fairly easy. First I had to set up a Linux environment to run Docker. I first decided to try Oracle an Oracle IaaS instance. If you are an Oracle Linux customer or just using the publicly available access an yum, you have what you need from Oracle Linux to run docker. (a separate blog post on this later). The documentation is here – https://docs.oracle.com/cd/E52668_01/E87205/html/index.html I also decided to try docker on the Mac. Once installed, Oracle Linux or the Mac, it works the same.
Here is what you do.
Login to the docker registry. Navigate to the database enterprise edition image and accept the terms and restrictions.
Then at the linux root prompt #
# docker login container-registry.oracle.com
# docker run -d -it –name MYDB container-registry.oracle.com/database/enterprise:18.104.22.168
(note above two dashes — before name)
That is pretty much it. Then you have a container running after you wait an hour or so for a 2.7G download. As documented, you can then connect to it by sqlplus doing the following.
# docker exec -it MYDB bash -c “source /home/oracle/.bashrc; sqlplus /nolog”
That is it. But why and when would I put the database in a container and most importantly, when would I definitely not at least today. That is a whole other topic which may be a topic of a separate post. With Oracle pluggable databases, we can have the best of both worlds and easily move our databases from running in a container to plugging into our on premise infrastructure to plugging into the Oracle Cloud.
So now, lets make this a bit more useful and look at some other docker commands. This took me a while to figure out since this was the first time working with docker.
We have docker images.
We have docker containers which is an instance of an image. When we created the database, we gave the image a name. MYDB. If we run that command multiple times, we would have had multiple containers created. Note that all the images are the same and so is the database inside — all PDB1.
#docker ps -a (all containers)
#docker ps (running containers)
From the docker ps, you can get the container ID. You can use that to do a
#docker stop <containerid>
#docker start <containerid>
Therefore, when you return to the environment, to continue to access the same database.
#docker ps -a (find the container you want to start and container name)
#docker start <containerID>
# docker exec -it <NAME> bash -c “source /home/oracle/.bashrc; sqlplus /nolog”
To connect from outside run
#docker port <NAME>
You should see something like –
1521/tcp -> 0.0.0.0:32769
5500/tcp -> 0.0.0.0:32768
Connect to the host on port 32769 and 32768 for the OracleNET and Database Express Services.
I set up a tunnel for my client over ssh to get to the server in the Oracle Cloud.
Macbook-Pro: ssh -L 32769:localhost:32769 -N opc@<ip address> -i <my key>
If you are on the machine running the containers, you would not need to set up a tunnel or if you had the other ports open, you could just reference the machines IP.
Then, I connected using SQL Developer.
In a future blog, I will look at the custom configurations. One key aspect here is that you can specify where the data files are stored outside of the container on and ext file system. The container registry points out that performance is better this way. Another advantage I can see here is that you then name you PDB. From there, I expect to find other advantages to help with working in the enterprise.
This post is subject to the following disclaimer.