Portainer icon

Portainer

Work with Portainer API data to manage Docker

Container → Create

AI-generated

Overview

This node operation creates a new Docker container in a specified environment using the Portainer API. It allows users to define container properties such as the container name, Docker image, command to execute, environment variables, exposed ports, port bindings, and restart policy. This operation is useful for automating container deployment and management in Docker environments managed by Portainer.

Use Case Examples

  1. Automatically deploy a web server container with specific ports exposed and environment variables set.
  2. Create a container running a custom command with defined port mappings and restart policies.

Properties

Name Meaning
Environment ID The ID of the environment/endpoint in Portainer where the container will be created.
Container Name The name to assign to the new container.
Image The Docker image to use for the container.
Command The command to execute inside the container.
Environment Variables List of environment variables to set inside the container, each with a name and value.
Exposed Ports Comma-separated list of ports to expose from the container.
Port Bindings Port mappings from container ports to host ports in the format container:host.
Restart Policy Policy defining when the container should be restarted (e.g., no, always, unless-stopped, on-failure).

Output

JSON

  • Id - The unique identifier of the created container.
  • Warnings - Any warnings returned by the Docker API during container creation.

Dependencies

  • Portainer API with an API key credential for authentication

Troubleshooting

  • Ensure the Environment ID corresponds to a valid and accessible Portainer environment.
  • Verify the Docker image name is correct and accessible from the environment's Docker registry.
  • Check that port bindings and exposed ports are correctly formatted and do not conflict with existing containers.
  • If the container creation fails, review the API response for error messages related to invalid parameters or resource limits.

Links

Discussion