New API Development Platform, join Blackbird Beta and try it now Learn More

Testing with Telepresence and Docker

Testing your microservices-based application becomes difficult when it can no longer be run locally due to resource requirements. Moving to the cloud for testing is a no-brainer, but how do you synchronize your local changes against your remote Kubernetes environment? Even with Docker Desktop making the container build-push-test cycle easy, this still takes time and introduces wasteful context switches for you as an engineer.

By using Telepresence with Docker, you get flexible remote development environments that work with your Docker toolchain so you can code and test faster for Kubernetes-based apps.

Get early access to the extension today:

  • Visit the Docker website and install Docker Desktop.
  • Read the Docker Desktop Extension for Telepresence docs here.

Need help with your Docker and Telepresence setup? Schedule a session with our team of experts here.

Telepresence / Docker Way

Traditional Way

  1. Code: Make changes to your app locally via IDE
  2. Build: Create container with code change: docker build
  3. Push: docker push
  4. Pause: wait for remote upload to remote registry
  5. Deploy: kubectl apply -f manifest.yaml (wait)
  6. Verify: Run tests against the staging cluster URL
  7. View: kubectl logs xyz -f
  8. Repeat: Identify new issue/bug and start this cycle again

Telepresence / Docker Way

  1. Code: Make changes to your app locally via IDE
  2. Build: Create container with code change: docker build
  3. Connect: Join your container’s network to the remote cluster: (push button)
  4. Verify: Use the auto-generated preview URL to view changes and run tests
  5. View: Access application logs locally via Docker Deskop UI or CLI e.g. docker logs
  6. Flow: Identify new issue/bug and begin fixing and verifying without repeating all the above steps

Try Telepresence & Docker with a sample app to see how fast your dev/test loop can be!

1. Enable and start your Docker Desktop Kubernetes cluster locally.

Install the Telepresence extension to Docker Desktop if you haven’t already.

2. Install the Emojivoto application in your local Docker Desktop cluster (we will use this to simulate a remote K8s cluster).

The Emojivoto application is a sample application that consists of three independent Kubernetes services: a frontend service (web) and two backend services (emoji and voting). Use the following command to apply the Emojivoto application to your cluster:

kubectl apply -k

3. Start the web service in a single container with Docker.

In addition to running the entire application in the Kubernetes cluster, we'll also start a containerized version of the web service. This will simulate a local dev/test loop of the frontend. Create a file called docker-compose.yml and paste the following into that file:

version: '3'



image: buoyantio/emojivoto-web:v11


- WEB_PORT=8080

- EMOJISVC_HOST=emoji-svc.emojivoto:8080

- VOTINGSVC_HOST=voting-svc.emojivoto:8080

- INDEX_BUNDLE=dist/index_bundle.js


- "8080:8080"

network_mode: host

In your terminal, run docker compose up to start running the web service locally.

4. Using a test container, curl the API endpoint in Emojivoto and watch it fail (because it can’t access the backend cluster).

In a new terminal, we will test the Emojivoto app with another container. Run the following command: docker run -it --rm --network=host alpine. Then we’ll install curl: apk --no-cache add curl

Finally, curl localhost:8080/api/list and you should get an rpc error message because we are not connected to the backend cluster and cannot resolve the emoji or voting services:

> docker run -it --rm --network=host alpine

apk --no-cache add curl



(1/5) Installing ca-certificates (20211220-r0)

(2/5) Installing brotli-libs (1.0.9-r5)

(3/5) Installing nghttp2-libs (1.46.0-r0)

(4/5) Installing libcurl (7.80.0-r0)

(5/5) Installing curl (7.80.0-r0)

Executing busybox-1.34.1-r3.trigger

Executing ca-certificates-20211220-r0.trigger

OK: 8 MiB in 19 packages

curl localhost:8080/api/list

{"error":"rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing dial tcp: lookup emoji-svc on no such host\""}

5. Run Telepresence connect via Docker Desktop.Open Docker Desktop and click the Telepresence extension on the left-hand side. Click the blue “Connect” button. Copy and paste an API key from Ambassador Cloud if you haven’t done so already ().

Select the cluster you deployed the Emojivoto application to by selecting the appropriate Kubernetes Context from the menu. Click next and the extension will connect Telepresence to your local cluster.

6. Re-run the curl and watch this succeed.

Now let’s re-run the curl command. Instead of an error, the list of emojis should be returned indicating that we are connected to the remote cluster:

/ # curl localhost:8080/api/list


Let’s intercept traffic to the web service and reroute it to the Docker Compose instance by creating a Telepresence intercept. Select the emojivoto namespace and click the intercept button next to “web”. Set target port to 8080 and service port 80 then create the intercept.

After the intercept is created, you will see it listed in the UI. Click the nearby blue button with three dots to access your preview URL. Open this URL in your browser and you can interact with your local instance of the web service with its dependencies running in your Kubernetes cluster.

Congratulations, you've successfully created a Telepresence intercept and a sharable preview URL! Send this to your teammates and they will be able to see the results of your local service interacting with the Docker Desktop cluster.

Need setup help?

Get help with Docker, Kubernetes, and cloud technologies from our team of experts