DEV Community

Geoffrey Kim
Geoffrey Kim

Posted on

Running Docker on macOS Without Docker Desktop

In our conversation, we discussed the feasibility of running Docker on macOS without relying on Docker Desktop and explored the reasons why Docker CLI alone suffices on Ubuntu but not on macOS. Here’s a detailed summary:

Why Docker Desktop Isn't Mandatory on macOS

While Docker Desktop provides an all-in-one solution for running Docker on macOS, it's not the only way to use Docker. You can utilize alternative tools to achieve the same result. Docker Desktop is popular for its ease of use and integration, but if you prefer not to use it, other methods are available.

Using Docker Without Docker Desktop

  1. Install Docker CLI:

    • On macOS, you can install the Docker CLI using Homebrew:
     brew install docker
    
  2. Running Docker Daemon:

    • Since macOS doesn't natively support Docker's underlying Linux kernel features, you need a lightweight virtual machine (VM) to run the Docker daemon.
    • Colima: One such tool is Colima, which can be installed via Homebrew:
     brew install colima
    
  • After installation, start Colima to initiate the Docker daemon:

     colima start
    
  1. Using Docker CLI:

    • Once Colima is running, you can manage Docker containers using the Docker CLI:
     docker run hello-world
    

Why Docker CLI Alone Works on Ubuntu

Docker works out-of-the-box on Ubuntu with just the CLI because:

  1. Linux Kernel: Ubuntu runs on the Linux kernel, which natively supports Docker's necessary features like namespaces and control groups (cgroups).
  2. Docker Daemon: On Ubuntu, the Docker CLI communicates directly with the Docker daemon running on the same Linux kernel, eliminating the need for a VM.

Differences in macOS and Ubuntu

  • Kernel Differences: macOS uses the Darwin kernel (BSD-based), which lacks the native support for Docker’s containerization technologies.
  • VM Requirement: To compensate, macOS uses a VM (via Docker Desktop or alternatives like Colima) to provide a Linux environment for Docker.

Conclusion

To sum up, while Docker Desktop simplifies the process of running Docker on macOS, it's not indispensable. By using alternative tools like Colima, you can set up a Docker environment without Docker Desktop. Understanding the kernel differences between macOS and Linux-based systems like Ubuntu explains why macOS requires additional steps to run Docker efficiently.

Top comments (0)