Docker Desktop can run a Kubernetes node that is accessible locally. It enables you to build and re-build local Docker images and have them available to Kubernetes pods for deployments.
For typical deployments in Kubernetes, you will want to specify a version tag for a Docker image.
For local development with Docker Desktop and Kubernetes, you can set the tag of the image latest
or development
, any tag without a version number.
You must also set the deployment's restartPolicy
to Always
and the container's imagePullPolicy
to IfNotPresent
. This ensures that Kubernetes can pull the image from Docker Desktop, and that it will always restart with the latest updated image.
Then you can run kubectl rollout restart deployment $DEPLOYMENT_NAME
to restart the pod and pull the latest development image.
The iteration cycle looks like this:
- Write code
- Build the image with the
development
tag - Restart the deployment
You can use fswatch or some other watch tool to monitor changes in source code and kick off the Docker image rebuild and then the Kubernetes deployment restart.
For monitoring the local Kubernetes cluster, I have been using Headlamp which is available as a Docker Desktop extension.
Check "Understand permission requirements for Docker Desktop on Mac" if there are permission or port issues.
Top comments (3)
Docker Desktop is not free for professional use. People use alternatives nowadays.
That's a fair point, from Docker's pricing page:
I know of Orbstack and it's possible to use microk8s with local Docker image repositories: microk8s.io/docs/registry-images
What are some other alternatives?
I use Orbstack, Rancher Desktop, or Podman Desktop, depending on the context or the preference of the infra team.
With a preference for Orbstack !