Run A Postgres Docker Container on Oracle Cloud Infrastructure

Why Oracle Cloud Infrastructure

Oracle Cloud Free Offering

Note: the workload of a container has to fit in the shape of this always free VM: VM.Standard.E2.1.Micro, 1/8 OCPU, 1 GB RAM and up to 480 Mbps network bandwidth (see [docs]( The boot volume offers just over 45GB of disk storage. In order for the container to be accessible, the ports mapped on the VM to container also have to be configured in ingress rules in the security list. We need to install Docker ourselves in the VM; it is provisioned with just an Oracle Linux image.

1) Get yourself a tenancy and create a VM

Example of provisioned VM from Oracle Developer Blog
Example of running VM from Oracle Developer Blog
Visualization of the VM setup from Oracle Developer Blog

2) Setup Ingress Rules in Security List for VM to open up the ports required for whatever container you want to run

Subnet Screen from Oracle Developer Blog
Ingress Rule Screenshot

3) SSH into the VM, install Docker

ssh opc@public-id-address -i private-key-file
sudo yum-config-manager — enable ol7_addons
sudo yum install docker-engine -y
sudo systemctl start docker
sudo systemctl enable docker
Docker installation screenshot from Oracle Developer Blog

Run Docker Container Image

sudo docker run -d -p 5432:5432 — name postgres -e POSTGRES_PASSWORD=mysecretpassword postgres
sudo docker exec -it postgres bash
root@12d48fde2627:/# psql -U postgres
psql (13.3 (Debian 13.3–1.pgdg100+1))
Type “help” for help.
postgres=# CREATE DATABASE testdb;
postgres=# \q

Congrats, you have now run A Postgres Docker Container on Oracle Cloud Infrastructure!




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store