TemperStack
Intermediate12 min readUpdated Mar 18, 2026

How to integrate Functions with containers on DigitalOcean

Quick Answer

DigitalOcean Functions can be integrated with containers by deploying containerized applications that trigger or invoke functions through HTTP endpoints or event-driven architectures. This enables hybrid serverless-container workflows for scalable applications.

Prerequisites

  1. Active DigitalOcean account
  2. DigitalOcean CLI (doctl) installed
  3. Docker installed locally
  4. Basic knowledge of serverless functions
1

Create a DigitalOcean Functions namespace

Navigate to the Functions section in your DigitalOcean dashboard and click Create Namespace. Enter a unique namespace name like my-container-functions and select your preferred region. Click Create Namespace to initialize the serverless environment.
Tip
Choose a region close to where your containers will be deployed for optimal performance
2

Deploy a function to handle container requests

Create a new function by clicking Create Function in your namespace. Select Node.js or Python runtime and name it container-handler. Write your function code to process requests from containers:

exports.main = async (args) => {
  const { payload } = args;
  // Process container data
  return { statusCode: 200, body: { result: 'processed', data: payload } };
};

Click Save and Deploy.
Tip
Functions automatically scale based on incoming requests from your containers
3

Set up a container application on DigitalOcean App Platform

Go to Apps in your dashboard and click Create App. Select Docker Hub or connect your Git repository containing a Dockerfile. Configure your container to make HTTP requests to your function endpoint. Add the function URL as an environment variable: FUNCTION_URL=https://faas-region.digitalocean.com/api/v1/namespaces/your-namespace/actions/container-handler.
4

Configure HTTP client in your container

In your container application code, implement HTTP requests to invoke the function. For example, in Node.js:

const axios = require('axios');

const invokeFunction = async (data) => {
  const response = await axios.post(process.env.FUNCTION_URL, {
    payload: data
  });
  return response.data;
};

Ensure your container handles authentication if your function requires it.
Tip
Use connection pooling and retry logic for robust function invocations
5

Set up event-driven integration using webhooks

Create a webhook endpoint in your function to receive events from external services or DigitalOcean resources. In your function code, add webhook handling:

if (args.__ow_method === 'POST' && args.__ow_path === '/webhook') {
  // Process webhook data
  const eventData = args.__ow_body;
  // Trigger container operations via API
}

Enable Web Action in your function settings to make it accessible via HTTP.
Tip
Validate webhook signatures to ensure secure event processing
6

Implement container-to-function authentication

Go to API section in DigitalOcean dashboard and generate an API token. In your container environment variables, add DO_API_TOKEN=your_api_token. Modify your function invocation code to include authentication headers:

headers: {
  'Authorization': `Bearer ${process.env.DO_API_TOKEN}`,
  'Content-Type': 'application/json'
}
Tip
Store API tokens securely using DigitalOcean App Platform's encrypted environment variables
7

Monitor and test the integration

Use the Functions dashboard to monitor invocations, errors, and performance metrics. Test your integration by triggering container operations that should invoke functions. Check the Logs tab in both your App Platform application and Functions namespace to verify successful communication. Set up alerts for failed function invocations.
Tip
Enable detailed logging in both containers and functions for easier debugging

Troubleshooting

Function timeout errors when called from containers
Increase the function timeout in the Settings tab of your function (maximum 15 minutes). Optimize your function code to reduce execution time and implement asynchronous processing for long-running tasks.
Container cannot reach function endpoint
Verify the function URL is correct and the function is deployed. Check that your container has internet access and the function namespace is in the same region. Ensure firewall rules allow outbound HTTPS traffic.
Authentication failures between container and function
Verify your API token is valid and has the correct permissions. Check that the token is properly set in your container environment variables. Ensure you're using the correct authentication header format in your HTTP requests.
High latency in function invocations
Deploy your containers and functions in the same region to reduce network latency. Implement connection pooling in your container code and consider using async function invocations for non-critical operations. Monitor function cold starts and optimize initialization code.

Related Guides

More DigitalOcean Tutorials

Other Tool Tutorials

Ready to get started with DigitalOcean?

Put this tutorial into practice. Visit DigitalOcean and follow the steps above.

Visit DigitalOcean