Actions72
- Image Actions
- Network Actions
- Node Actions
- Registry Actions
- Secret Actions
- Service Actions
- Stack Actions
- Team Actions
- Template Actions
- User Actions
- Volume Actions
- Webhook Actions
- Config Actions
- Container Actions
- Edge Group Actions
- Edge Stack Actions
Overview
This node integrates with the Portainer API to manage Docker containers and other Docker-related resources. Specifically, the Container - Create operation allows users to create new Docker containers on a specified Portainer environment (endpoint). This is useful for automating container deployment workflows directly from n8n without manually interacting with Docker or Portainer UI.
Typical use cases include:
- Automatically deploying containers based on dynamic inputs or triggers.
- Creating containers with specific configurations such as environment variables, port mappings, and restart policies.
- Integrating container creation into larger automation pipelines involving Docker services, images, or stacks.
For example, you could use this node to deploy an Nginx container with custom ports and environment variables whenever a new application version is released.
Properties
| Name | Meaning |
|---|---|
| Environment ID | The ID of the Portainer environment/endpoint where the container will be created. |
| Container Name | Optional name to assign to the new container. |
| Image | Docker image to use for the container (e.g., nginx:latest). |
| Command | Optional command to run inside the container, specified as a string (will be split by spaces). |
| Environment Variables | List of environment variables to set inside the container. Each variable has a Name and a Value. |
| Exposed Ports | Comma-separated list of ports to expose on the container (e.g., 80,443). |
| Port Bindings | Comma-separated port mappings in the format containerPort:hostPort (e.g., 80:8080,443:8443). |
| Restart Policy | Container restart policy; options are: No, Always, Unless Stopped, On Failure. |
Output
The node outputs the JSON response returned by the Portainer API after creating the container. This typically includes details about the newly created container such as its ID and any warnings.
The output JSON structure corresponds to the Portainer/Docker API response for container creation, which usually contains:
Id: The unique identifier of the created container.Warnings: Any warnings generated during creation.
No binary data is produced by this operation.
Dependencies
Requires a configured Portainer API credential with:
- Base URL of the Portainer instance.
- An API key/token for authentication.
The node sends HTTP requests to the Portainer API endpoint
/endpoints/{environmentId}/docker/containers/create.Proper network access to the Portainer server is necessary.
Troubleshooting
Invalid Environment ID: If the environment ID does not correspond to a valid Portainer endpoint, the API will return an error. Verify the environment ID is correct.
Image Not Found: If the specified Docker image does not exist or cannot be pulled, container creation will fail. Ensure the image name and tag are correct and accessible.
Port Binding Conflicts: Incorrect or conflicting port bindings may cause errors. Confirm that host ports are available and correctly mapped.
Authentication Errors: Missing or invalid API key will result in authorization failures. Check the Portainer API credentials configuration.
Malformed Environment Variables: Environment variables must be provided as name-value pairs. Improper formatting can cause request rejection.
Common error messages come directly from the Portainer API and usually indicate issues with parameters or authentication. Reviewing the API response message helps identify the root cause.