NashTech Blog

COLIMA an alternative for run Docker without UI on MacOS

Table of Contents

Introduction

Docker is a cornerstone of modern development, but sometimes, the full-fledged desktop applications can feel like overkill. Especially if you’re a command-line warrior who prefers a lighter, more efficient workflow. That’s where Colima comes in.

What is Colima?

Colima (Container runtimes on macOS) is a minimalist container runtime that lets you run Docker (and containerd) on macOS with minimal overhead. Think of it as a lightweight alternative to Docker Desktop, perfect for those who primarily interact with Docker through the command line.

Why Colima?

  • Lightweight and Fast: Colima is designed to be lean, consuming fewer system resources compared to Docker Desktop. This translates to faster startup times and smoother performance, particularly on less powerful machines.
  • Command-Line Focused: If you’re comfortable with the command line, Colima is your ideal partner. It integrates seamlessly with your terminal, allowing you to manage containers without a bulky GUI.
  • Flexibility: Colima supports both Docker and containerd, giving you the flexibility to choose your preferred container runtime.
  • Easy Installation and Configuration: Getting started with Colima is a breeze. Installation is straightforward, and configuration options allow you to tailor it to your specific needs.
  • Open Source and Free: Colima is an open-source project, meaning it’s free to use and supported by a vibrant community.

How Colima Works

Colima leverages virtualization frameworks like vz (Virtualization.framework) on macOS 12+ and QEMU to create a lightweight Linux virtual machine. This VM acts as the host for your container runtime.

Getting Started with Colima

  1. Prerequisites:
    • Ensure you have Homebrew installed. If not, install it from brew.sh.
  2. Installation:
    • Open your terminal and run: brew install colima
  3. Basic Configuration and Starting Colima:
    • The simplest way to start Colima with default settings is: colima start
    • However, you’ll likely want to customize your setup. Here are some common configuration options:
      • --cpu <number>: Sets the number of CPUs allocated to the VM. Example: --cpu 4
      • --memory <GB>: Sets the amount of memory allocated to the VM in gigabytes. Example: --memory 8
      • --disk <GB>: Sets the disk size allocated to the VM in gigabytes. Example: --disk 60
      • --runtime docker or --runtime containerd: Specifies the container runtime. Defaults to Docker.
      • --vm-type vz or --vm-type qemu: Selects the virtualization type. vz is recommended for macOS 12+ for better performance.
    • Example of a customized start command:Bashcolima start --cpu 4 --memory 8 --disk 60 --vm-type vz
    • After executing the start command, Colima will download the necessary VM image and start the container runtime.
  4. Using Docker:
    • Once Colima is running, you can use the docker command as you normally would. For example:
      • docker run hello-world (to test your setup)
      • docker pull nginx (to download an image)
      • docker ps (to list running containers)
      • docker images (to list downloaded images)
  5. Basic Colima Commands:
    • colima status: Checks the status of the Colima VM.
    • colima stop: Stops the Colima VM.
    • colima restart: Restarts the Colima VM.
    • colima delete: Deletes the Colima VM and its data. (Use with caution!)
  6. Port Forwarding:
    • If you need to access services running inside your Docker containers from your host machine, you’ll need to use port forwarding. Docker handles this as normal. For example: docker run -p 8080:80 nginx will forward port 8080 on your host to port 80 in the container.
  7. Volumes and File Sharing:
    • Docker volumes work as expected within Colima. You can mount directories from your macOS host into your containers.
    • Ensure that the files you want to share are located within your user directory, as this is the default shared directory.

Troubleshooting:

  • If you encounter issues, check the Colima GitHub repository for common problems and solutions.
  • Ensure your macOS version is compatible with the selected virtualization type.
  • Verify that you have sufficient disk space and memory available.

Who Should Use Colima?

  • Developers who prefer a command-line workflow.
  • Users with limited system resources.
  • Those who need a fast and lightweight container runtime.
  • Individuals who want to avoid the overhead of a full-fledged Docker Desktop application.

In Conclusion

Colima provides a streamlined and efficient way to run Docker on macOS. By understanding the basic setup and configuration options, you can tailor Colima to your specific needs and enjoy a faster, more responsive container development experience.

This significant resource consumption can lead to performance degradation, especially when running multiple Docker containers at the same time. Furthermore, the large size of Docker Desktop can hinder its deployment in environments with restricted network bandwidth or storage limitations. The question needs to be resolved. Is there a way to use Docker without installing Docker Desktop? The answer is YES.

References

Colima repository: https://github.com/abiosoft/colima

Picture of Loc Tran

Loc Tran

Software Engineer at NashTech VN

Leave a Comment

Your email address will not be published. Required fields are marked *

Suggested Article

Scroll to Top