Docker Inc has updated their terms on the usage of Docker-Desktop with affects from the 31st of August 2021.
According to the updated terms, Docker-Desktop is licensed as part of a free (Personal) or paid Docker subscription (Pro, Team or Business). Docker Desktop can be used for free as part of a Docker Personal subscription for small companies, personal use, education and learning purposes and non-commercial open source projects.
In short, Docker Desktop for Mac/Windows is no longer free for “professional use in larger companies”
Note:
Docker Desktop enables developers to locally build, share, and run containerised applications and micro services. Docker Desktop includes Docker Engine, Docker CLI client, Docker Build/BuildKit, Docker Compose, Docker Content Trust, Kubernetes, Docker Scan, and Credential Helper.
In this post we are going to explore an alternative option to run docker container in Mac without using Docker-Desktop.
Note:
Windows users can use Docker CE with Windows Subsystem for Linux (WSL2), this option is not available for Mac users.
We are going to use free open source alternative for Docker Desktop: Lima-VM, containerd and nerdctl
Nerdctl uses almost similar syntax as docker, so it would be handy to create the following alias to make the usage of nerdctl commands easier.
alias docker="lima nerdctl"
Now we can execute nerdctl commands in the same way we executed docker commands,
$ docker ps -a
$ docker run -p 3309:3306 --name=mysql -d mysql/mysql-server mysqld --lower_case_table_names=0
What is "Lima-VM" ?
Since containers are based on Linux-specific technologies like cgroups and namespaces, in order to run containers on any system we need to run linux virtual machine on the host system (bare-metal hypervisor OR hosted hypervisor).
Lima (Linux Machines) is an open source vm which enables to run linux virtual machines with automatic file sharing, port forwarding (similar to WSL2), and containerd.
Installing containerd on Mac from scratch is a tedious and long task, need to compile sources. This is the main motivation of the Lima project.
Lima projects wraps QEMU hypervisor with containerd and nerdctl (contaiNERD ctl) as a homebrew package.
The design of Lima is similar to WSL2, but Lima focuses on macOS as the primary target host. Lima currently does not support Windows hosts.
What is "containerd" ?
containerd is the container engine which manages the complete container lifecycle of its host system, from image transfer and storage to container execution and supervision to low-level storage to network attachments and beyond.
containerd also implements CRI spec (Container Runtime Interface) to support Kubernetes implementations.
containerd is a daemon, listening on a Unix socket, exposes gRPC endpoints. Handles all the low-level container management tasks, storage, image distribution, network attachment, etc...
containerd came from docker, it is made CRI-complaint to support Kubernetes through its CRI plugin.
What is "nerdctl" ?
nerdctl is the native user-friendly command line interface developed to execute containerd commands. Similar to Docker CLI.
nerdctl features and commands are almost identical as Docker CLI, however, nerdctl also supports several cutting-edge features of containerd that are not present in Docker.
Such features include, but not limited to, lazy-pulling (stargz) and running encrypted images (ocicrypt).
Quick Start
Install Lima
Lima can now be installed on both Intel and ARM based Macs through the Homebrew package manager,
$ brew install lima
Start Lima
Execute the following command to start the lima vm,
$ limactl start
Proceed with the default configurations and wait until Lima completes downloading and launching the VM image.
After seeing “READY” output, run the following command to confirm that the VM is now running.
$ lima uname -a
Linux lima-default 5.13.0-27-generic #29-Ubuntu SMP ... aarch64 aarch64 aarch64 GNU/Linux
Run a Container with "lima nerdctl"
Create the following alias in the .bashrc Or .zshrc file based on your configuration,
alias docker="lima nerdctl"
Execute the following command to spin up a containerised MySQL Server using lima nerdctl,
docker run -p 3309:3306 --name=mysql -d mysql/mysql-server mysqld
--lower_case_table_names=0
We can list all the docker containers by executing the following command,
docker ps -a
References:
Hope this blog helped you to learn some thing new today. Thank you for reading!
Cheers!!!
Comments