Learn how to install and run Docker and Kubernetes using Colima, an Open Source alternative to Docker Desktop.

After the updates to Docker Desktop's license agreement, other solutions for running Docker on your local machine have been brought to attention. These include Vagrant VM (https://blog.avenuecode.com/running-docker-in-a-vagrant-vm), WSL2 (https://blog.avenuecode.com/running-docker-engine-on-wsl-2), and Minikube (https://blog.avenuecode.com/running-docker-in-a-minikube-cluster), among others.

However, it's time to focus on Colima for several reasons. First, it's an open-source solution, making it adaptable to changes. Second, it offers container runtimes on macOS and Linux with minimal setup. Finally, it boasts features such as support for Intel and M1 Mac chips, port forwarding, Docker, Containerd, and Kubernetes.

This article will guide you through the installation and use of Docker and Kubernetes.

Installation

For all the steps, we're using a Mac with an Intel chip. The installation can be done through other resources, but we'll present it using Homebrew.

Installing Homebrew:

/bin/bash -c "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

With Homebrew installed, we can now install Colima:

brew install colima

Running Docker

To run Docker with Colima, you first need to download the free Docker CLI. This can be accomplished by executing the following command:

brew install docker

Then, we can start Colima. When running Docker, we can simply use the following command.

colima start

By running the following command, we can view the details of the Virtual Machine (VM) that is running Docker.

colima status

image (5)-2

By default, Colima creates a VM with 2 CPUs, 2GiB of memory, and 60GiB of storage. However, you can override these settings when starting the VM using the following command:

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

If multiple VMs are running, they can be listed using the following command:

colima list

image (6)-4

In addition, Colima has other flags that can be utilized during startup.

image (8)-1

You should now be prepared to use the Docker CLI on the host:

docker run hello-world

To stop the process, simply use:

colima stop

Running Kubernetes

Running Kubernetes is as straightforward as running Docker. First, we need to install Kubernetes.

brew install kubectl

Then, we can start Colima with the following flag:

colima start --kubernetes

Now we can test to see if everything has been successfully set up.

kubectl cluster-info

image (9)-2

To stop, we can use the identical command:

colima stop

Connecting VSCode to Docker

To use VSCode in connection with your container, follow these straightforward steps. Begin by installing the Docker extension from the extension list.

image (10)-3

After installation, use the shortcut Cmd+Shift+P and select Dev Containers:

image (11)-2

Afterward, you should be able to view all the containers currently running.

image (12)-2

A new window will open, attaching VSCode to your container.

References

https://github.com/abiosoft/colima

https://blog.avenuecode.com/running-docker-in-a-minikube-cluster

https://blog.avenuecode.com/running-docker-in-a-vagrant-vm

https://blog.avenuecode.com/running-docker-engine-on-wsl-2


Author

João Fekete

João Fekete is a backend developer with a broad skillset and a passion for learning. He actively seeks opportunities to connect diverse areas of knowledge to solve problems.


Running Docker in a Minikube Cluster

READ MORE

Your 60-Second Intro to GKE

READ MORE

Debugging Remote/Containerized Apps with VS Code

READ MORE