Set Up a Docker Environment on macOS with Colima

Published: 2025-02-23

When setting up a Docker environment on your PC, Docker Desktop is often the first choice.

Docker Desktop is easy to set up, comes with a user-friendly GUI, and supports Kubernetes. However, it may offer more features than needed, and in some cases, a paid plan is required for commercial use.

In this post, I’ll introduce Colima, a lightweight alternative to Docker Desktop for running Docker on macOS without relying on Docker Desktop.


What is Colima?

Colima (Container on Lima) is a lightweight virtualization tool that enables Docker or containerd to run on macOS. It leverages Lima (Linux Machines) to create a virtualized Linux environment, allowing Docker Engine or Kubernetes to run seamlessly on macOS.

Key Features:

  • Simple setup: Get started with just a single command.
  • Lightweight: Uses fewer system resources compared to Docker Desktop.
  • Kubernetes Support: Easily enable Kubernetes with colima start --kubernetes.
  • Free & open source: Licensed under MIT, with no restrictions on commercial use.

Prerequisites

  • Homebrew installed

Install packages with Homebrew

Install Docker with Homebrew:

brew install docker

Install Colima with Homebrew:

brew install colima

Start Colima

Start Colima:

colima start

By default, the VM is created with 2 CPUs, 2 GiB of memory, and 100 GiB of storage.

You can customize these configurations using --cpu , --memory, and --disk options:

colima start --cpu 1 --memory 2 --disk 10

Check the status of Colima:

colima status

If you see “colima is running”, then Colima has started successfully.

Verify Docker is Running

Check the Docker version.

docker version

If you see Server information displayed, Docker is runninc correctly in Colima.

Run a Docker Container

Run the hello-world Docker container to test if Docker is working:

docker run hello-world

If you see the message “Hello from Docker!”, Docker is working correctly.

Stop Colima

You can stop Colima with this command:

colima stop

Clean Up Colima

To delete all Colima resources, use:

colima delete

⚠ CAUTION: This command will delete all container data and settings. Use it with care.

(Optional) Using Kubernetes

Before trying this, you need to delete any existing Colima instance using:

colima delete

Prerequisites: Ensure kubectl installed.

Start Colima with Kubernetes

To enable Kubernetes support, start Colima with the --kubernetes options:

colima start --kubernetes

Run a Kubernetes pod

You can start a simple Nginx pod using:

kubectl run hello-world --image=nginx --restart=Never

Note: The --restart=Never option creates a standalone pod instead of a Deployment.

Verify Kubernetes is Running:

Check the status of your pod:

kubectl get pods

If the status is Running, the pod is successfully running. It is still ContainerCreating, wait a few seconds and check again. You can also watch for updates in real-time:

kubectl get pods -w

To inspect the pod’s logs:

kubectl logs hello-world

Wrap up

In this post, I provided basic guide to set up a Docker environment with Colima.

Colima is easy to use, lightweight, and enhances your development environment without the need for Docker Desktop.

Happy developing!

Reference