Skip to main content
In this lesson we’ll demonstrate running the Telepresence user daemon inside a Docker container on your local machine. Running Telepresence in Docker is less intrusive than changing host networking, avoids requiring elevated privileges, and makes it easier to run Telepresence alongside other local tooling.
A presentation slide with "Demo" on the left and a turquoise curved panel on the right reading "Telepresence with Docker." The slide also shows a small "© Copyright KodeKloud" note in the bottom-left corner.
Prerequisites:
  • Telepresence installed (v2.x+ recommended)
  • Docker installed and running
  • Access to a Kubernetes cluster (context configured)

1) Run the Telepresence user daemon inside Docker

First, disconnect any active Telepresence session and then connect using the --docker flag to run the Telepresence user daemon inside a container:
You should see console output similar to:
Verify the Telepresence status and confirm the daemon runs in a container:
Example (abridged) status output:
And confirm with Docker:
Example:
Running Telepresence inside Docker avoids changing host networking and needing admin privileges while still enabling Kubernetes service interception and local debugging workflows.

2) Intercept cluster traffic to a local Docker container

The common workflow is to intercept traffic destined for a Kubernetes Service/Deployment and forward it to a process running locally. With Telepresence you can run that process inside a Docker container. Example Node.js “auth” service (index.js):
Build an image and create an intercept that runs your image locally with --docker-run:
When you run an intercept with --docker-run, Telepresence starts the specified image locally and attaches the intercept so cluster traffic to the intercepted service is routed to that container. Confirm the container is running:

The double dash (--) separates flags intended for Telepresence from flags and arguments passed to Docker (for example -v, -e, or the container’s CMD). Everything after -- is treated as Docker arguments.

3) Example: Product service — modify code, build, and intercept

Make code changes to the products service and run it locally via Telepresence. The snippet below shows an async route that fetches inventory data, merges it into product objects, and returns the combined result. Replace the inventory fetch URL with the appropriate service address in your setup (for example http://inventory-service:3000).
Build the Docker image:
Intercept the products-depl deployment and run your image locally:
Sample Telepresence intercept output (abridged):
Test via the product service external endpoint (replace the example ELB host with your own):
Example JSON response:

4) Avoid rebuilding images on every change — use bind mounts and hot-reload

Rebuilding images for every code change slows down iteration. Use Docker bind mounts to map your local source directory into the container and override the container command to a development runner (for example npm run dev using nodemon) so the container picks up file changes instantly. Example: bind-mount the current directory into /usr/src/app in the container and run npm run dev:
Notes:
  • -v $(pwd):/usr/src/app mounts your local project into the container path expected by your Dockerfile.
  • my-test-image is the base image used to start the container.
  • npm run dev (after the image name) becomes the container’s command so nodemon will hot-reload on file changes.
Example nodemon container logs:
When you update local files, nodemon restarts the server inside the container immediately because the source is bind-mounted.

5) Let Telepresence build the image for you with —docker-build

If you prefer Telepresence to build the image automatically, use --docker-build and --docker-build-opt to pass build options like tag=. Telepresence expects a literal IMAGE token at the end (after the final --) which it replaces with the built image. Example:
Notes:
  • products/ is the path with your Dockerfile.
  • --docker-build-opt tag=my-debug-image tags the generated image as my-debug-image.
  • The literal IMAGE token is required; Telepresence uses it to hook the built image into the intercept.
Verify the container and the built image:
Example snippets:
You can still use bind mounts (-v) and override commands with --docker-build to enable hot-reload workflows.

Quick reference: common Telepresence + Docker commands


Summary

  • Use telepresence connect --docker to run the Telepresence user daemon inside a Docker container.
  • Use telepresence intercept ... --docker-run -- <image> [docker-args] [cmd] to run a local container as the intercept target.
  • Use Docker bind mounts (-v) and override the container command (e.g., npm run dev) to enable hot-reload without rebuilding images.
  • Use --docker-build and --docker-build-opt to have Telepresence build the image for you.
  • The -- separator is critical: flags before it apply to Telepresence; everything after it is passed to Docker.
Links and further reading:

Watch Video