8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23ai | Misc | PL/SQL | SQL | RAC | WebLogic | Linux
Home » Articles » Linux » Here
Podman : A Basic Example of Using Podman With Dockerfiles (Oracle Database and ORDS) on Oracle Linux 8 (OL8)
This articles shows how to use Podman with existing Dockerfiles as a replacement for Docker. It is not meant as a best practice for how to use Podman, but a simple example for people with existing Docker experience.
- My Setup
- Clone the Git Repository
- Make Docker Hub Available
- Pull Oracle Linux 8 Image
- Build the Database Image
- Build the ORDS Image
- Create a Pod
- Create a Database Container
- Create an ORDS Container
- Test It
- Stopping/Starting the Containers
- Remove the Containers and Pod
Related articles.
- Using Podman With Existing Dockerfiles (Oracle Database and ORDS)
- Podman : Install Podman on Oracle Linux 8 (OL8)
- Docker/Container Articles
My Setup
This article described how to install Podman on Oracle Linux 8 (OL8).
I'm doing this installation on my Vagrant build for Podman (here). These are the important locations on the VM.
# The base location for the Git repositories. BASE_DIR=/u01 # The directory where all the software is sitting on host. SOFTWARE_DIR=/vagrant/software
If you are running this example from the Vagrant build, the Docker Hub repository (docker.io) is already enabled. There is also a user called "container_user" set up, which can run the podman command without the need for "sudo". The commands in this article assume you have a similar setup. If not, simply add "sudo " to the start of each command.
We need a location to use for persistent storage, so we create the following directories and change their ownership so the container can read/write to them.
mkdir -p /u01/volumes/ol8_19_ords_tomcat mkdir -p /u01/volumes/ol8_19_ords_db # As root. groupadd -g 1042 container_fg chown -R :container_fg /u01 chmod -R 775 /u01/volumes chmod -R g+s /u01/volumes usermod -aG container_fg container_user
Clone the Git Repository
Clone my Dockerfiles repository. We are going to use them without any amendments.
cd ${BASE_DIR} git clone https://github.com/oraclebase/dockerfiles.git
Make Docker Hub Available
If you are used to using Docker and want to make Docker Hub images available, make the following change in the "/etc/containers/registries.conf" file.
# From: [registries.search] registries = ['container-registry.oracle.com', 'registry.access.redhat.com', 'registry.redhat.io'] # To: [registries.search] registries = ['container-registry.oracle.com', 'docker.io', 'registry.access.redhat.com', 'registry.redhat.io']
Pull Oracle Linux 8 Image
Pull the latest "oraclelinux:8" image from Docker Hub.
podman pull oraclelinux:8-slim
Build the Database Image
We switch to the "software" directory for the database build, copy the software into place, switch back to the main directory and perform the build.
cd ${BASE_DIR}/dockerfiles/database/ol8_19/software cp ${SOFTWARE_DIR}/LINUX.X64_193000_db_home.zip . cp ${SOFTWARE_DIR}/apex_20.1_en.zip . cd ${BASE_DIR}/dockerfiles/database/ol8_19 podman build --format docker --no-cache -t ol8_19:latest .
Build the ORDS Image
We switch to the "software" directory for the ORDS build, copy the software into place, switch back to the main directory and perform the build.
cd ${BASE_DIR}/dockerfiles/ords/ol8_ords/software cp ${SOFTWARE_DIR}/apex_20.1_en.zip . cp ${SOFTWARE_DIR}/apache-tomcat-9.0.34.tar.gz . cp ${SOFTWARE_DIR}/ords-19.4.0.352.1226.zip . cp ${SOFTWARE_DIR}/sqlcl-19.4.0.354.0937.zip . cp ${SOFTWARE_DIR}/OpenJDK11U-jdk_x64_linux_hotspot_11.0.7_10.tar.gz . cd ${BASE_DIR}/dockerfiles/ords/ol8_ords podman build --format docker --no-cache -t ol8_ords:latest .
Create a Pod
A pod houses zero to many containers. All containers in the pod can automatically talk to each other on the ports exposed by the containers, so we don't have to worry about any explicit networking. We do have to decide which ports we want to expose to the host server.
Create a new Pod called "my_pod" and make sure the correct ports are exposed. Multiple ports can be created as comma-separated list using the "-p" or "--publish" flag. In the example below we've explicitly listed the "host:container" relationship for each port.
podman pod create --name my_pod --publish=1521:1521,5500:5500,8080:8080,8443:8443
We can see information about the pod using the "ls" and "inspect" commands.
podman pod ls podman pod inspect my_pod
It is possible to create a pod automatically using the podman create
or podman run
commands to create a container. Using the --pod=new:{pod_name}
flag creates a new pod with the specified name and associates the new container with it.
podman run -dit \ --name={container_name} \ --pod=new:{pod_name} ...
The pod takes on the characteristics of the container, so I don't like this option. It feels better to create the pod explicitly.
Create a Database Container
We create containers in the normal manner, but instead of using the "--network" flag, we use the "--pod" flag to indicate which pod the container should be created inside. We are going to use the default environment settings inside the container, including all the passwords. This would be silly for a real container, but for this example it keeps things simple. Notice the use of the "--volume" flag to specify the persistent storage.
podman run -dit \ --name=ol8_19_con \ --pod=my_pod \ --volume=/u01/volumes/ol8_19_ords_db/:/u02 \ ol8_19:latest
We can track the progress of the container start up using the following command.
podman logs --follow ol8_19_con
Create an ORDS Container
We create an ORDS container in a similar manner. We used the default environment settings for the database, so we can mostly use the default environment settings for the ORDS container, as the database port, service and passwords will be set to the same default values. We do need to tell the container where to find the database using the "-e" flag. For Docker we would specify the container name, but for Podman we just use localhost.
podman run -dit \ --name ol8_ords_con \ --pod=my_pod \ -e="DB_HOSTNAME=localhost" \ -v=/u01/volumes/ol8_19_ords_tomcat:/u01/config/instance1 \ ol8_ords:latest
We can track the progress of the container start up using the following command.
podman logs --follow ol8_ords_con
Test It
Once both containers are running in the pod, we can access ORDS in the normal way and we'll be presented with the APEX login screen.
https://localhost:8443/ords/
Stopping/Starting the Containers
We can stop and start containers individually, or via the pod.
# Stop all containers in the pod. podman pod stop my_pod # Start all containers in the pod. podman pod start my_pod # Stop containers individually. podman stop ol8_ords_con podman stop ol8_19_con # Start containers individually. podman start ol8_ords_con podman start ol8_19_con
Remove the Containers and Pod
The containers need to be stopped and removed before we can remove the pod. We stop all containers in the pod.
podman pod stop my_pod
Now we can remove the containers and remove the pod.
podman rm -vf ol8_ords_con podman rm -vf ol8_19_con podman pod rm my_pod
For more information see:
- Podman
- Welcome to Podman’s documentation!
- Using Podman With Existing Dockerfiles (Oracle Database and ORDS)
- Podman : Install Podman on Oracle Linux 8 (OL8)
- Docker/Container Articles
Hope this helps. Regards Tim...