Portainer icon

Portainer

Work with Portainer API data to manage Docker

Service → Create

AI-generated

Overview

This node operation creates a new Docker Swarm service in a specified environment using the Portainer API. It allows users to define the service name, Docker image, number of replicas, and environment variables for the service container. This operation is useful for automating the deployment and management of Docker Swarm services within a Portainer-managed environment.

Use Case Examples

  1. Automate deployment of a web application service using a specific Docker image and environment variables.
  2. Create multiple instances of a microservice by specifying the number of replicas.
  3. Set up a new service in a Docker Swarm cluster managed by Portainer with custom environment variables.

Properties

Name Meaning
Environment ID The ID of the environment/endpoint in Portainer where the service will be created.
Image The Docker image to use for the service container.
Environment Variables A collection of environment variables to set inside the service container.
Service Name The name to assign to the new Docker Swarm service.
Replicas The number of replicas (instances) of the service to run.

Output

JSON

  • Name - The name of the created service.
  • TaskTemplate
    • ContainerSpec
      * Image - The Docker image used by the service container.
      * Env - The environment variables set for the service container.
  • Mode
    • Replicated
      * Replicas - The number of replicas configured for the service.

Dependencies

  • Portainer API with an API key credential for authentication

Troubleshooting

  • Ensure the Environment ID is correct and the Portainer endpoint is accessible.
  • Verify the Docker image name is valid and accessible from the environment.
  • Check that the API key credential has sufficient permissions to create services.
  • If environment variables are not applied, ensure they are correctly formatted as name-value pairs.

Links

Discussion