Running “docker compose” in a VM on Oracle Cloud Infrastructure is perhaps not the ideal way to go – which probably would be OKE (Kubernetes) in order to benefit most from modern container infrastructure features and leverage the underlying VMs the most. However, sometimes falling back on what works and what is already available, tried and tested is quite appealing. I had to get an application to run (Angular, Spring, Java, PostgreSQL) that consisted of a yaml file configuring Docker Compose using two container images. All I need to get this application to run is the yaml file, an environment that can access Docker Hub to pull the images and the ability to interpret the docker compose yaml file.
Oracle Cloud Infrastructure (OCI) makes it quite easy to run a Compute Instance (VM). It provides a short cut wizard style “create and run new Compute Instance” in its portal that allows selection of the proper VM Image and automatically configures the VCN and subnet to provide the required network access to the VM. When one selects the Oracle Linux Cloud Developer image, the VM comes complete with many runtime software components including Java runtime, Python, Graal VM, Ansible, OCL CLI on top of Oracle Enterprise Linux. The VM does not come with Docker and Docker Compose (as in the past it used to) but instead provides Podman (and podman-docker that allows one to use Docker CLI commands that are turned into Podman instructions).
The VM does not come with either Docker Compose (docker-compose) or Podman Compose (podman-compose). In order to do the “docker compose up” thing, we need to install & configure some components. This article shows what I did – and what made it work.
I relied on several resources to help me out, such as this article (Podman Docker Compose: How to? by Manu Menon ) that explains more about Podman Compose and how to install it. This article explains a little more about Podman Compose and how to use it.
The first steps – getting a VM to run on OCI and access it remotely – are described in my earlier article “Quickstart a Compute Instance on OCI”; it includes instructions on network configuration and accessing the VM from a local terminal window or from VS Code.
Fine Tuning OCI VM for use of Podman Compose
As per the instructions in the article by Manu Menon mentioned before, I need to update existing and install new packages and configure a socket. The article did not mention the podman-compose package – which is the crucial one as I found out.
The steps are:
1. Install/upgrade a bunch of packages. I am not sure this step is required: all these packages were already installed in the VM. Some underlying packages were updated and perhaps that is useful or even required. Perhaps not.
sudo dnf install -y podman podman-docker
2. Install podman-compose – this package most certainly did not yet exist
sudo dnf install -y podman-compose
3. Enable the podman.socket
sudo systemctl enable podman.socket
sudo systemctl start podman.socket
sudo systemctl status podman.socket
This creates a Unix socket in which Docker (Podman) Compose can communicate and symlinks it to /var/run/docker.sock.
Test the socket communication by running the curl command given below.
sudo curl -H “Content-Type: application/json” –unix-socket /var/run/docker.sock http://localhost/_ping
The output of this last command should be OK
4. The preparation is complete. At this point, podman compose can run – just as docker compose.
I have created a local yaml file with the content from my application’s docker-compose.yml file:
I can now run the application using podman compose:
podman-compose –f app.yml up
after a little while both images have been pulled and the application is started:
I can check that both containers I expect are running – and the application is functioning:
Note: I had to define firewall rules in order to allow incoming requests to port 8080 where the application is handling browser requests. That has nothing to do with Podman.
When the request comes into the application,
it is handled by the backend running in two containers managed by Podman Compose.