[macOS] Use Homebrew (brew) to install Docker Desktop, Docker Compose and Kubernetes (K8S) on macOS
Docker Desktop, Docker Compose and Kubernetes (K8S) on macOS
Docker Desktop is an easy-to-install application for your Mac or Windows environment that enables you to build and share containerized applications and microservices. Docker Desktop includes Docker Engine, Docker CLI client, Docker Compose, Docker Content Trust, Kubernetes, and Credential Helper.
Some of the key features of Docker Desktop include:
-
Ability to containerize and share any application on any cloud platform, in multiple languages and frameworks
-
Easy installation and setup of a complete Docker development environment
-
Includes the latest version of Kubernetes
-
Automatic updates to keep you up to date and secure
-
On Windows, the ability to toggle between Linux and Windows Server environments to build applications
-
Fast and reliable performance with native Windows Hyper-V virtualization
-
Ability to work natively on Linux through WSL 2 on Windows machines
-
Volume mounting for code and data, including file change notifications and easy access to running containers on the localhost network
-
In-container development and debugging with supported IDEs
Installation
Install Homebrew (brew).
1 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
Insall Docker Desktop.
1 | brew install --cask docker |
Check Docker and Docker Compose version.
1 | $ docker -v |
Enable Kubernetes
Docker Desktop includes a standalone Kubernetes server and client, as well as Docker CLI integration that runs on your machine. The Kubernetes server runs locally within your Docker instance, is not configurable, and is a single-node cluster.
The Kubernetes server runs within a Docker container on your local system, and is only for local testing. Enabling Kubernetes allows you to deploy your workloads in parallel, on Kubernetes, Swarm, and as standalone containers. Enabling or disabling the Kubernetes server does not affect your other workloads.
To enable Kubernetes support and install a standalone instance of Kubernetes running as a Docker container, go to Preferences
> Kubernetes
and then click Enable Kubernetes
.
Click Apply & Restart
to save the settings and then click Install to confirm. This instantiates images required to run the Kubernetes server as containers, and installs the /usr/local/bin/kubectl
command on your machine.
1 | kubectl version |
FAQs
Kubernetes failed to start
Choose Troubleshoot
from the menu bar to see the troubleshoot options.
The Troubleshoot page contains the following options:
-
Restart Docker Desktop: Select to restart Docker Desktop.
-
Support: Developers on Pro and Team plans can use this option to send a support request. Other users can use this option to diagnose any issues in Docker Desktop. For more information, see Diagnose and feedback and Support.
-
Reset Kubernetes cluster: Select this option to delete all stacks and Kubernetes resources. For more information, see Kubernetes.
-
Clean / Purge data: This option resets all Docker data without a reset to factory defaults. Selecting this option results in the loss of existing settings.
-
Reset to factory defaults: Choose this option to reset all options on Docker Desktop to their initial state, the same as when Docker Desktop was first installed.
-
Uninstall: Choose this option to remove Docker Desktop from your system.
Kubernetes starting
May be can’t download k8s images from k8s.gcr.io in the limited network environment. Please check you network to download these images from k8s.gcr.io, or from other mirrors.
Pull and tag multiple images.
Remember to replace coredns:1.8.0
and pause:3.4.1
with your prefer image and version.
1 | REGISTRY_MIRROR=registry.aliyuncs.com/google_containers |
References
[1] docker — Homebrew Formulae - https://formulae.brew.sh/cask/docker
[3] Docker Desktop for Mac and Windows | Docker - https://www.docker.com/products/docker-desktop
[4] Install Docker Compose | Docker Documentation - https://docs.docker.com/compose/install/
[5] Deploy on Kubernetes | Docker Documentation - https://docs.docker.com/desktop/kubernetes/
[8] The Missing Package Manager for macOS (or Linux) — Homebrew - https://brew.sh/
[9] Kubernetes