Open ifoche opened 4 years ago
Check capabilities required:
$ token=$(curl -H "Content-Type: application/json" -sS \
-d '{"Username": "admin", "Password": "123123123"}' -X POST localhost:9000/api/auth \
| jq '.jwt' -r)
$ curl -H "Authorization: Bearer $token" http://localhost:9000/api/endpoints | jq
[x] Forgot password: Currently not supported (see here). Only hacky workaround is to manually edit its BoltDB config file (here).
[x] Get status (json): /api/stacks
does not list compose (external) stacks (see here) . Therefore, we must use the docker/containers endpoint (api/endpoints/1/docker/containers/json
. Example response here)
[x] Get status (html): Options: There is no embed/plugin feature, so we'd need to use an iframe with a proxy_pass
so both the container and the wrapper page have the same host and port. Then we can tweak its contents. Example: document.getElementById("portainer").contentWindow.document.querySelector("#sideview").remove()
[x] Create compose container: Stacks -> Add stack for docker-compose (note: only version 2 supported) type is a create-only operation. The stack is deployed, but now you cannot get its attributes, just inspect the container info and you do with any other container. So we cannot store this data, but should read from existing d2-docker containers already created. Do we really need own DB?
[x] Start/stop compose container: portainer does not provide endpoints for this, it simply uses the docker API: /api/endpoints/1/docker/containers/123/start
. So we'd need start the containers manually, with no docker-compose support. Default operation would be equivalent to d2-docker start -k
using the last port used.
[x] Delete compose container: External docker-compose stacks are not deletable. You delete the containers instead (use ../docker API). As /api/stacks
does not return docker-compose stacks, you must get manually them from the docker->compose listing.
[x] Teams: It's only a group of users, no roles can be assigned. We need users to be admins (User details -> Administrator) to access the API
[x] If we need arbitrary commands (d2-docker) to be run, check: https://github.com/treytabner/rest-shell, https://github.com/vrest-io/vutil
[x] Direct API docker access: sudo curl -s --unix-socket /var/run/docker.sock http://docker/images/json | jq