To pull the Oracle image from the Oracle registry, run the Oracle 12c container from the Oracle Container Registry (OCR). Follow these steps:
- From your local host, log in to Oracle Container Registry and provide the credentials.
[root@12c-docker ~] # Docker login container-registry.oracle.com
- Open a web browser, log in to the OCR, provide your Oracle support ID and password, and select a database.
- Select the Oracle database 12.2.0.1 Docker image.
- Pull the 12c Docker image from the OCR.
Note: Having access to high-quality container images from a trusted source can save many hours of labor that are typically required to create and manage images that are built locally from Docker files. Always check requirements before attempting to deploy a container image.
[root@12c-docker ~] # docker pull container-registry.oracle.com/database/enterprise:12.2.0.1
- Display the Docker images.
[root@12c-docker ~] #docker images
- To save bandwidth, we recommend using the option to set up a private Docker registry for running the containers. Follow these steps to set up a local private registry:
- [root@12c-docker ~] # mkdir -p /opt/registry/data
- [root@12c-docker ~] # mkdir -p /var/lib/registry
- [root@12c-docker ~] #docker run -d -p 5000:5000 --name registry -v /opt/registry/data:/var/lib/registry/ --restart always registry
- Tag the Oracle 12c image with the local host.
[root@12c-docker ~] #docker tag container-registry.oracle.com/database/enterprise:12.2.0.1 localhost:5000/ora12C
- Push the Oracle 12c image to the local repository.
[root@12c-docker ~] # docker push localhost:5000/ora12c
Note: If you customize the Oracle container image, save both the base image and any customization to the local private registry with appropriate annotations, if required, for your business use case.
- Examine the contents of the local repository.
[root@12c-docker ~] # ls -ll /opt/registry/data/docker/registry/v2/repositories/
- On the host OS, create a Docker volume named “test” and mount it on /home/oracle. Oracle Linux administrators can also use bind mounts to ensure local persistence and avoid data loss. (Add a bind mount to the File Systems table in your server’s File Systems Table (fstab)). Though bind mounts are better suited for the Oracle database usage within a container environment, volumes are the preferred mechanism for persisting data generated by and used by Docker containers. In other words, volumes have several advantages over bind mounts; these advantages are described in Docker docs. For Use Case 1, Dell Technologies used Docker volumes. To create Docker volumes, run these commands:
- [root@12c-docker ~] #docker volume create --driver local --opt type=none --opt device=/home/oracle/ --opt o=bind test
- [root@12c-docker ~] #docker volume create -d local -o Mountpoint=/home/oracle --name=test
- Create any necessary groups and users. To implement the security and access mechanism within Oracle database, create groups and valid permissions and add them to the Oracle users as described in the steps below.
- [root@12c-docker oracle] # groupadd -g 54321 oinstall
- [root@12c-docker oracle] # groupadd -g 54322 dba
- [root@12c-docker oracle] # useradd -u 54321 -g oinstall -G dba oracle
- Because we are hosting database files in the /home/oracle directory on the local host, avoid permissions issues from subsequent commands by changing the permissions of this directory:
- [root@12c-docker oracle] # chown -R oracle: dba /home/oracle
- [root@12c-docker oracle] # chmod -R 777 /home/oracle
- Create the Oracle database within the container with the parameters shown below:
[root@12c-docker ~] #docker run -d --name database12c -p 1521:1521 -p 5500:5500 -e ORACLE_SID=ORCLCDB -e ORACLE_PDB=orclpdb1 -e ORACLE_PWD=oracle -v test:/ORCL localhost:5000/ora12c
- Log into the 12c container. In this step we execute an interactive bash shell on the container to run the Oracle 12c database services that are running inside the Docker container. Subsequently we will log in to the Oracle 12c database residing within the container.
[root@12c-docker ~] # docker exec -it 3804167e17da bash[oracle@3804167e17da ~] $ sqlplus "/ as sysdba"