Portainer icon

Portainer

Work with Portainer API data to manage Docker

Stack → Update

AI-generated

Overview

This node operation updates an existing Docker Compose stack in Portainer. It allows users to modify the stack by providing the stack ID, environment ID (endpoint), the updated stack file content (docker-compose.yml), and optional environment variables. Users can also specify whether to prune services that are no longer referenced in the updated stack. This operation is useful for managing and maintaining Docker stacks through Portainer's API, enabling automated updates and configuration changes to containerized applications.

Use Case Examples

  1. Updating a stack's docker-compose.yml file to deploy new service versions or configuration changes.
  2. Adding or modifying environment variables for a stack to change runtime behavior.
  3. Pruning unused services from a stack to clean up resources.

Properties

Name Meaning
Environment ID The ID of the environment/endpoint in Portainer where the stack is deployed.
Stack ID The unique identifier of the stack to update.
Stack File Content The contents of the docker-compose.yml file or stack file defining the stack's services and configuration.
Environment Variables A collection of environment variables to set for the stack, each with a name and value.
Prune Services A boolean flag indicating whether to prune services that are no longer referenced in the updated stack.

Output

JSON

  • body - The JSON response from Portainer API after updating the stack, typically containing the updated stack details or status.

Dependencies

  • Portainer API with an API key credential for authentication

Troubleshooting

  • Ensure the Environment ID and Stack ID are correct and correspond to existing resources in Portainer.
  • Verify that the stack file content is valid YAML and correctly formatted as a docker-compose file.
  • If environment variables are provided, ensure they are correctly formatted as name-value pairs.
  • Check API key permissions to confirm the user has rights to update stacks.
  • Common errors include 404 Not Found if the stack or environment does not exist, 400 Bad Request for invalid stack file content, and 401 Unauthorized if API credentials are invalid.

Links

Discussion