Portainer icon

Portainer

Trabalhe com dados da API do Portainer para gerenciar Docker

Overview

This node integrates with the Portainer API to manage Docker Swarm services. Specifically, the Service - Get operation retrieves detailed information about a specific Docker Swarm service identified by its Service ID within a given environment (endpoint). This is useful for monitoring, auditing, or automating workflows that depend on the current state or configuration of Docker services managed via Portainer.

Common scenarios:

  • Fetching service details before performing updates or scaling operations.
  • Auditing service configurations in automated CI/CD pipelines.
  • Integrating service metadata into dashboards or reporting tools.

Practical example:
You want to retrieve the configuration and status of a Docker Swarm service named "webapp" running in your production environment (Environment ID 1) to verify its image version and replica count before deploying an update.

Properties

Name Meaning
Environment ID The ID of the Portainer environment/endpoint where the Docker service is running.
Service ID The unique identifier of the Docker Swarm service to retrieve information about.

Output

The node outputs JSON data representing the full details of the requested Docker Swarm service as returned by the Portainer API. This includes all service metadata such as:

  • Service name, ID, and labels
  • Task template including container specs (image, environment variables, command arguments)
  • Mode and replica settings
  • Endpoint specifications like published ports
  • Update and rollback configurations
  • Current service status and version info

No binary data output is involved in this operation.

Dependencies

  • Requires a configured Portainer API credential with:

    • Base URL of the Portainer instance
    • An API key token for authentication
  • The node makes HTTP GET requests to the Portainer API endpoint:

    /endpoints/{environmentId}/docker/services/{serviceId}
    
  • Ensure the Portainer instance is accessible from the n8n environment.

Troubleshooting

  • Common issues:

    • Invalid or missing Environment ID or Service ID parameters will cause the request to fail.
    • Network connectivity problems between n8n and the Portainer API.
    • Insufficient permissions or invalid API key leading to authorization errors.
  • Error messages:

    • 404 Not Found: The specified service ID does not exist in the given environment.
      • Verify the Service ID and Environment ID are correct.
    • 401 Unauthorized or 403 Forbidden: Authentication failed.
      • Check the API key credential and ensure it has proper access rights.
    • 500 Internal Server Error: Portainer API encountered an error.
      • Retry later or check Portainer server logs for more details.

Links and References

Discussion