Deploy on Kubernetes with Docker Desktop
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. It runs within a Docker container on your local system, and is only for local testing.
Turning on Kubernetes allows you to deploy your workloads in parallel, on Kubernetes, Swarm, and as standalone containers. Turning on or off the Kubernetes server does not affect your other workloads.
Install and turn on Kubernetes
-
From the Docker Desktop Dashboard, select the Settings.
-
Select Kubernetes from the left sidebar.
-
Next to Enable Kubernetes, select the checkbox.
-
Select Apply & Restart to save the settings and then select 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.Important
The
kubectl
binary is not automatically packaged with Docker Desktop for Linux. To install the kubectl command for Linux, see Kubernetes documentation. It should be installed at/usr/local/bin/kubectl
.
By default, Kubernetes containers are hidden from commands like docker ps
, because managing them manually is not supported. Most users do not need this option. To see these internal containers, select Show system containers (advanced).
When Kubernetes is turned on and running, an additional status bar in the Docker Desktop Dashboard footer and Docker menu displays.
Note
Docker Desktop does not upgrade your Kubernetes cluster automatically after a new update. To upgrade your Kubernetes cluster to the latest version, select Reset Kubernetes Cluster.
Use the kubectl command
Kubernetes integration provides the Kubernetes CLI command
at /usr/local/bin/kubectl
on Mac and at C:\Program Files\Docker\Docker\Resources\bin\kubectl.exe
on Windows. This location may not be in your shell's PATH
variable, so you may need to type the full path of the command or add it to
the PATH
.
If you have already installed kubectl
and it is
pointing to some other environment, such as minikube
or a GKE cluster, ensure you change the context so that kubectl
is pointing to docker-desktop
:
$ kubectl config get-contexts
$ kubectl config use-context docker-desktop
Tip
Run the
kubectl
command in a CMD or PowerShell terminal, otherwisekubectl config get-contexts
may return an empty result.If you are using a different terminal and this happens, you can try setting the
kubeconfig
environment variable to the location of the.kube/config
file.
If you installed kubectl
using Homebrew, or by some other method, and
experience conflicts, remove /usr/local/bin/kubectl
.
You can test the command by listing the available nodes:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
docker-desktop Ready control-plane 3h v1.29.1
For more information about kubectl
, see the
kubectl
documentation.
Turn off and uninstall Kubernetes
To turn off Kubernetes in Docker Desktop:
- From the Docker Desktop Dashboard, select the Settings icon.
- Select Kubernetes from the left sidebar.
- Next to Enable Kubernetes, clear the checkbox
- Select Apply & Restart to save the settings.This stops and removes Kubernetes containers, and also removes the
/usr/local/bin/kubectl
command.