š Setting Up Docker and Docker Compose on Oracle Cloudās Always Free Tier Instance
Table of contents
- š What You Get with Oracle Cloudās Always Free Tier
- š„ļø Step-by-Step Guide: Setting Up Docker and Docker Compose
- Step 1: Provision an Always Free Instance
- Step 2: Update System Packages
- Step 3: Install Docker
- Step 4: Install Docker Compose
- Step 5: Installing Standalone Docker Compose (Optional)
- Step 6: Enable Docker for Non-Root Users
- Step 7: Automate the Installation with a Wrapper Script
- Step 8: Run the Wrapper Script
- ā Final Verification
- š Conclusion
Oracle Cloud Infrastructure (OCI) offers a generous Always Free Tier thatās perfect for developers and homelab enthusiasts looking to run containerized applications. In this guide, Iāll show you how to:
Summarize the key benefits of the Always Free Tier.
Set up Docker and Docker Compose on an ARM-based instance (
VM.Standard.A1.Flex
).Automate the installation using a wrapper script for easy deployments.
š What You Get with Oracle Cloudās Always Free Tier
Oracleās Always Free resources are persistent and donāt expire, unlike other cloud providersā time-limited trials. Hereās what you get for free:
1. Compute Instances
VM.Standard.A1.Flex (ARM-based)
Up to 4 OCPUs and 24 GB RAM split across multiple instances.
Suitable for Docker containers, self-hosted applications, and development environments.
VM.Standard.E2.Micro (Intel/AMD-based)
1 OCPU and 1 GB RAM.
Great for small services like web servers, monitoring tools, or DNS services.
2. Storage
200 GB block storage (total): Attach to any compute instance.
20 GB object storage: For static files or backups.
10 GB archive storage: For long-term storage.
3. Autonomous Databases
- 2 autonomous databases (20 GB each) for lightweight app backends or data analytics.
4. Networking
Virtual Cloud Network (VCN) with free load balancing (10 Mbps).
Site-to-Site VPN for connecting on-premise infrastructure to OCI.
ā Learn more: Oracle Always Free Tier Documentation
š„ļø Step-by-Step Guide: Setting Up Docker and Docker Compose
Weāll set up Docker and Docker Compose on a VM.Standard.A1.Flex instance running Oracle Linux 8 or a compatible ARM-based Linux distribution.
Step 1: Provision an Always Free Instance
Log in to your Oracle Cloud Console.
Navigate to Compute > Instances and click Create Instance.
Choose the VM.Standard.A1.Flex shape and allocate the following:
OCPUs: 2 (or up to 4 depending on your requirements)
RAM: 12 GB (or as needed)
Attach a 200 GB block volume (if desired).
Complete the configuration and launch the instance.
Step 2: Update System Packages
SSH into your instance and run the following commands to update the package manager.
sudo yum update -y
Step 3: Install Docker
- Install required dependencies:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
- Add Dockerās official repository:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- Install Docker:
sudo yum install -y docker-ce docker-ce-cli containerd.io
- Enable and start the Docker service:
sudo systemctl start docker
sudo systemctl enable docker
- Verify the installation:
docker run hello-world
Step 4: Install Docker Compose
Starting from Docker Compose v2, the Compose functionality is integrated into the Docker CLI, available through docker compose
. However, if needed, you can also install the standalone version.
To check if Docker Compose is already available:
docker compose version
If the integrated version is present, youāre good to go! If not, follow the steps below to install the standalone version.
Step 5: Installing Standalone Docker Compose (Optional)
Download the latest version dynamically from GitHub:
DOCKER_COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep tag_name | cut -d '"' -f 4)
sudo curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Apply executable permissions:
sudo chmod +x /usr/local/bin/docker-compose
Verify the installation:
docker-compose version
Step 6: Enable Docker for Non-Root Users
By default, you need sudo
to run Docker commands. To fix this, add your user to the docker
group:
sudo usermod -aG docker $USER
Apply the changes by logging out and back in or running:
newgrp docker
Now you can run Docker commands without sudo
:
docker version
docker compose version
Step 7: Automate the Installation with a Wrapper Script
Hereās a complete wrapper script that installs Docker and Docker Compose, checks for existing installations, and configures non-root access.
#!/bin/bash
# Check for Docker installation
if ! [ -x "$(command -v docker)" ]; then
echo "Docker not found. Installing Docker..."
# Update system and install required dependencies
sudo yum update -y
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Add Docker repository
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker
sudo yum install -y docker-ce docker-ce-cli containerd.io
# Enable and start Docker
sudo systemctl start docker
sudo systemctl enable docker
echo "Docker installed successfully."
else
echo "Docker is already installed."
fi
# Check if user is already in the docker group
if groups $USER | grep &>/dev/null '\bdocker\b'; then
echo "User $USER is already part of the docker group."
else
echo "Adding $USER to the docker group..."
sudo usermod -aG docker $USER
echo "You must log out and log back in to use Docker without sudo."
fi
# Check for Docker Compose (plugin or standalone)
if docker compose version &>/dev/null; then
echo "Docker Compose is already available via the Docker plugin:"
docker compose version
else
echo "Installing standalone Docker Compose..."
# Get the latest version of Docker Compose
DOCKER_COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep tag_name | cut -d '"' -f 4)
# Download and install
sudo curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo "Standalone Docker Compose installed successfully."
docker-compose version
fi
echo "Docker and Docker Compose setup is complete. Remember to log out and log back in if needed."
Step 8: Run the Wrapper Script
- Save the script as
install_docker.sh
:
nano install_docker.sh
- Make it executable:
chmod +x install_docker.sh
- Run the script:
./install_docker.sh
ā Final Verification
After running the script, verify Docker and Docker Compose:
docker version
docker compose version
š Conclusion
Youāve now set up Docker and Docker Compose on an ARM-based Oracle Cloud instance using the Always Free Tier! With this setup, you can:
Run containerized applications (e.g., Nginx, PostgreSQL, Redis).
Explore Kubernetes with microservices.
Host self-managed applications like Nextcloud or Home Assistant.
The possibilities are endless! š
Let me know in the comments if you tried this or if youād like to see more cloud/container-related tutorials. š