DEV Community

Rudolf Olah
Rudolf Olah

Posted on • Edited on

Kubernetes and Docker Desktop for Fast Local Development

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:

  1. Write code
  2. Build the image with the development tag
  3. 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)

Collapse
 
bcouetil profile image
Benoit COUETIL 💫

Docker Desktop is not free for professional use. People use alternatives nowadays.

Collapse
 
rudolfolah profile image
Rudolf Olah • Edited

That's a fair point, from Docker's pricing page:

Commercial use of Docker Desktop at a company of more than 250 employees OR more than $10 million in annual revenue requires a paid subscription (Pro, Team, or Business).

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?

Collapse
 
bcouetil profile image
Benoit COUETIL 💫 • Edited

I use Orbstack, Rancher Desktop, or Podman Desktop, depending on the context or the preference of the infra team.

With a preference for Orbstack !