edited screen snap breaking out topics for Docker Cloud swarm mode added another where-to-next link added more where-to-next links added back in on-page TOC for create swarm topic incorporated Ryan's review comments on first draft more Ryan's review comments, sweep thru all for consistency, notoc on short pages, etc. removed duplicate link to 'create a new swarm in docker cloud' Laura's comments incorporated re-organized Cloud topics, added in Swarm Mode Ryan's review comments on Cloud, added new type of advisory for Beta previews more review comments, manage infrastructure --> standard mode fixing image testing cloud images updates to Cloud welcome page for Swarm, non-Swarm descriptions add new cloud repository image retake of corrupted image fixed the other instance of corrupted image by referencing the retake fixing corrupted image on GitHub Signed-off-by: Victoria Bialas <victoria.bialas@docker.com>
1.6 KiB
description, keywords, redirect_from, title, notoc
| description | keywords | redirect_from | title | notoc | |
|---|---|---|---|---|---|
| API Roles | API, Services, roles |
|
Service API roles | true |
You can configure a service so that it can access the Docker Cloud API. When you grant API access to a service, its containers receive a token through an environment variable, which is used to query the Docker Cloud API.
Docker Cloud has a "full access" role which when granted allows any operation
to be performed on the API. You can enable this option on the Environment variables screen of the Service wizard, or specify it in your service's stackfile. When enabled, Docker Cloud generates an authorization token for the
service's containers which is stored in an environment variable called
DOCKERCLOUD_AUTH.
Use this variable to set the Authorization HTTP header when calling
Docker Cloud's API:
$ curl -H "Authorization: $DOCKERCLOUD_AUTH" -H "Accept: application/json" https://cloud.docker.com/api/app/v1/service/
You can use this feature with Docker Cloud's automatic environment variables, to let your application inside a container read and perform operations using Docker Cloud's API.
$ curl -H "Authorization: $DOCKERCLOUD_AUTH" -H "Accept: application/json" $WEB_DOCKERCLOUD_API_URL
For example, you can use information retrieved using the API to read the linked endpoints, and use them to reconfigure a proxy container.
See the API documentation for more information on the different API operations available.