Powered by Ilhasoft's Web Team.
Portainer CLI is a Python software to use in command line. Use this command line interface to easy communicate with your Portainer application, like in a continuous integration and continuous deployment environments.
pip install [--user] portainer-cli
| Flag | Description |
|---|---|
-l or --local |
Save and load configuration file (.portainer-cli.json) in current directory. |
-d or --debug |
Enable DEBUG messages in stdout |
Configure Portainer HTTP service base url.
portainer-cli configure base_urlE.g:
portainer-cli configure http://10.0.0.1:9000/Identify yourself and take action.
portainer-cli login username passwordE.g:
portainer-cli login douglas d1234Identify yourself using an API-Key. Generate your API-Key using the Portainer Web Interface (account -> add access token).
portainer-cli set_apikey <your-api-key>E.g:
portainer-cli set_apikey ptr_2Igx1JRPcKAKx5Q7k4R9wAYdLQBhJ+S62g+6sh7fA/w=Create a stack.
portainer-cli create_stack -n stack_name -e endpoint_id -sf stack_fileE.g:
portainer-cli create_stack -n stack_name -e 1 stack-test -sf docker-compose.yml| Flag | Description |
|---|---|
-n or -stack-name |
Stack name |
-e or -endpoint-id |
Endpoint id (required) |
-sf or -stack-file |
Stack file |
-ef or -env-file |
Pass env file path, usually .env |
Update a stack.
portainer-cli update_stack -s stack_id -e endpoint_id -sf stack_fileE.g:
portainer-cli update_stack -s 18 -e 1 -sf docker-compose.ymlportainer-cli update_stack id -s stack_id -e endpoint_id -sf stack_file --env.var=valueWhere var is the environment variable name and value is the environment variable value.
| Flag | Description |
|---|---|
-s or -stack-id |
Stack id |
-e or -endpoint-id |
Endpoint id (required) |
-sf or -stack-file |
Stack file |
-ef or -env-file |
Pass env file path, usually .env |
-p or --prune |
Prune services |
-c or --clear-env |
Clear all environment variables |
Create or update a stack based on it's name.
portainer-cli create_or_update_stack -n stack_name -e endpoint_id -sf stack_fileE.g:
portainer-cli update_stack -s 18 -e 1 -sf docker-compose.ymlportainer-cli create_or_update_stack -n stack_name -e endpoint_id -sf stack_file --env.var=valueWhere var is the environment variable name and value is the environment variable value.
| Flag | Description |
|---|---|
-n or -stack-name |
Stack name |
-e or -endpoint-id |
Endpoint id (required) |
-sf or -stack-file |
Stack file |
-ef or -env-file |
Pass env file path, usually .env |
-p or --prune |
Prune services |
-c or --clear-env |
Clear all environment variables |
Update acl associated to a stack
portainer-cli update_stack_acl -s stack_id -e endpoint_id -o ownership_typeRemark : you can either update by stack_id or stack_name (-s or -n)
E.g:
portainer-cli update_stack_acl -n stack-test -e 1 -o restricted -u user1,user2 -t team1,team2| Flag | Description |
|---|---|
-s or -stack-id |
Stack id |
-n or -stack-name |
Stack name |
-e or -endpoint-id |
Endpoint id (required) |
-o or -ownership-type |
Ownership type (admin |
-u or -users |
Comma separated list of user names (when restricted) |
-t or -teams |
Comma separated list of team names (when restricted) |
-c or -clear |
Clear users and teams before updateing them (when restricted) |
Get stack id by it's name. return -1 if the stack does not exist
portainer-cli get_stack_id -n stack_name -e endpoint_idE.g:
portainer-cli get_stack_id -n stack-test -e 1| Flag | Description |
|---|---|
-n or -stack-name |
Stack name |
-e or -endpoint-id |
Endpoint id (required) |
Update registry.
portainer-cli update_registry id [-name] [-url]E.g:
portainer-cli update_registry 1 -name="Some registry" -url="some.url.com/r"You can use authentication passing -a or --authentication flag, but you must pass the -username and -password options.
portainer-cli update_registry 1 -a -username=douglas -password=d1234Make a request.
portainer-cli request path [method=GET] [data]E.g:
portainer-cli request status| Flag | Description |
|---|---|
-p or --printc |
Print response content in stdout. |
This project use Pipenv to manager Python packages.
With Pipenv installed, run make install to install all development packages dependencies.
Run make lint to run flake8 following PEP8 rules.
Run make or make sdist to create/update dist directory.