
- 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:
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):--docker-run:
--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 theproducts 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).
products-depl deployment and run your image locally:
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 examplenpm 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:
-v $(pwd):/usr/src/appmounts your local project into the container path expected by your Dockerfile.my-test-imageis 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.
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:
products/is the path with your Dockerfile.--docker-build-opt tag=my-debug-imagetags the generated image asmy-debug-image.- The literal
IMAGEtoken is required; Telepresence uses it to hook the built image into the intercept.
-v) and override commands with --docker-build to enable hot-reload workflows.
Quick reference: common Telepresence + Docker commands
Summary
- Use
telepresence connect --dockerto 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-buildand--docker-build-optto have Telepresence build the image for you. - The
--separator is critical: flags before it apply to Telepresence; everything after it is passed to Docker.