Deploy to KubernetesEstimated reading time: 3 minutes
Kubernetes is only available in Docker for Windows 18.02 CE Edge. Kubernetes support is not included in Docker for Windows 18.02 CE Stable. To find out more about Stable and Edge channels and how to switch between them, see General configuration.
Docker for Windows 18.02 CE Edge includes a standalone Kubernetes server and client, as well as Docker CLI integration. 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. When Kubernetes support is enabled, you can deploy your workloads, in parallel, on Kubernetes, Swarm, and as standalone containers. Enabling or disabling the Kubernetes server does not affect your other workloads.
See Docker for Windows > Getting started to enable Kubernetes and begin testing the deployment of your workloads on Kubernetes.
Use Docker commands
You can deploy a stack on Kubernetes with
docker stack deploy, the
docker-compose.yml file, and the name of the stack.
docker stack deploy --compose-file /path/to/docker-compose.yml mystack docker stack services mystack
You can see the service deployed with the
kubectl get services command.
Specify a namespace
By default, the
default namespace is used. You can specify a namespace with
docker stack deploy --namespace my-app --compose-file /path/to/docker-compose.yml mystack
kubectl get services -n my-app to see only the services deployed in the
Override the default orchestrator
While testing Kubernetes, you may want to deploy some workloads in swarm mode.
DOCKER_ORCHESTRATOR variable to override the default orchestrator for
a given terminal session or a single Docker command. This variable can be unset
(the default, in which case Kubernetes is the orchestrator) or set to
kubernetes. The following command overrides the orchestrator for a single
deployment, by setting the variable
before running the command.
set DOCKER_ORCHESTRATOR=swarm docker stack deploy --compose-file /path/to/docker-compose.yml mystack
Note: Deploying the same app in Kubernetes and swarm mode may lead to conflicts with ports and service names.
Use the kubectl command
The windows Kubernetes integration provides the Kubernetes CLI command
C:\>Program Files\Docker\Docker\Resources\bin\kubectl.exe. This location may not be in your shell’s
variable, so you may need to type the full path of the command or add it to
PATH. For more information about
kubectl, see the
You can test the command by listing the available nodes:
kubectl get nodes NAME STATUS ROLES AGE VERSION docker-for-desktop Ready master 3h v1.8.2
Docker has created the following demo app that you can deploy to swarm mode or
to Kubernetes using the
docker stack deploy command.
version: '3.3' services: web: build: web image: dockerdemos/lab-web volumes: - "./web/static:/static" ports: - "80:80" words: build: words image: dockerdemos/lab-words deploy: replicas: 5 endpoint_mode: dnsrr resources: limits: memory: 16M reservations: memory: 16M db: build: db image: dockerdemos/lab-db
If you already have a Kubernetes YAML file, you can deploy it using the