Update: I've moved my setup process to Dockerize Oracle and APEX to Github. It will be maintained with the latest steps I'm using it. The repository is docker-oracle-setup.
I recently had a need to do a Proof of Concept (POC) on a new feature released in Oracle 12c R2 (12.2). My first instinct was to go to my DBAs and ask them to give me access to a 12.2 environment. Thankfully I was at the Oracle ACE annual Oracle Open World dinner and Gerald Venzl (aka Mr.Oracle-Docker) was there and convinced me otherwise. I must thank Gerald for both pushing me to start using Docker again and also for some support when I ran into issues.
The following post will cover how to get a 12.2 instance up and running using the Oracle Container Registry for your own personal instances
Background
- If you haven't already done so, go install Docker. If you've never heard of Docker before I suggest reading a bit about it so you have some understanding of what is and how it works.
- Go to container-registry.oracle.com and use your Oracle Technology Network (OTN) login and register.
- One logged in go to
Database > Enterprise and read and if you agree to the Terms and Conditions click the Accept button
Docker
The following steps will pull the appropriate image(s) and setup your docker instance. I've added inline comments to describe each step. If you're new to Docker please read my comments rather than blindly running the code.
docker pull container-registry.oracle.com/database/enterprise:12.2.0.1
docker run -d -it --name OracleDB -p 32711:1521 container-registry.oracle.com/database/enterprise:12.2.0.1
docker ps
docker port OracleDB
Your docker container should now be running. The following code shows how to connect to the instance using SQLcl along with creating a test account on the PDB. You can take the connection strings in the SQLcl demos and apply to SQL Developer.
sqlcl sys/Oradoc_db1@localhost:32711/orclpdb1.localdomain as sysdba
In SQL>:
define new_user = 'martin'
create user &new_user. identified by &new_user. container = current;
grant connect, resource, create any context to &new_user;
alter user &new_user quota unlimited on users;
exit
Connect to the PDB
sqlcl martin/martin@localhost:32711/orclpdb1.localdomain
Note: In SQL Developer this connection looks like:
{% asset_img docker-sql-developer.png %}
In SQL>
@https://raw.githubusercontent.com/OraOpenSource/OXAR/master/oracle/emp_dept.sql
commit;
exit;
You can now do/test whatever you want to do in your PDB!
Common docker commands
So now that you've started your Docker instance, and established a working connection to the PDB how do you manage the Docker container? Here are some useful Docker commands:
docker ps -a
docker stop -t 100 OracleDB
docker start OracleDB
docker rm OracleDB
docker rmi container-registry.oracle.com/database/enterprise:12.2.0.1
Final Thoughts
I've just started to use the Docker 12.2 image and may launch a 12.1 container as well (will blog instructions if I do it).
If I run into any issues doing my tests and "learning" development (i.e. kicking the 12.2 tires) I'll write another article and link below. I also plan to look into upgrading APEX on the 12.2 container along with creating a simple web server container to test APEX with some 12.2 features. If I get this working I'll blog about it.
Update: Role Hartman wrote a followup post to this article that I highly suggest reading. I will update this article with some of his suggestions on how he sets up his Docker Oracle DB container.