Question

App Platform: Route request to specific container

Lets say I have an App on App Platform with a single component which has many containers running.

If I expose say a /metrics endpoint it could be served by any of the containers.

Is there a way for me to route requests to a specific container? I have noticed that there is an environment variable called HOSTNAME that is unique for each container such as “component-7f844c67c-7c4bx” which looks like it could work but it doesn’t appear to resolve DNS.

// The address of my app https://app-kssfa.ondigitalocean.app

// Some of the formats I have tried https://app-kssfa.component-56447c7b7d-jv862.ondigitalocean.app https://component-56447c7b7d-jv862.ondigitalocean.app


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
January 15, 2025

Hey David! 👋

In the DigitalOcean App Platform, requests are routed through a load balancer by default, which distributes traffic evenly across all running containers for scalability and reliability. Unfortunately, directly routing requests to a specific container isn’t supported because containers are designed to be stateless and interchangeable.

However, if specific behavior is needed for certain routes, you could split your app into multiple components and use path-based routing to direct traffic to the right component.

Example:

  • /api/v1 → Component A
  • /api/v2 → Component B

📖 More on URL Path Routing

If container-specific routing is critical, using Droplets with Nginx/HAProxy or a managed DigitalOcean Kubernetes cluster might give you the fine-grained control you need.

Let me know if any of these work for you!

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.