# Use API to start new container from catalog

**URL:** <https://forums.suse.com/t/use-api-to-start-new-container-from-catalog/3084>\
**Category:** Rancher 1.x\
**Created:** [June 10, 2016, 10:43am UTC](https://forums.suse.com/t/use-api-to-start-new-container-from-catalog/3084 "2016-06-10T10:43:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmls](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/jmls/32/1419_2.png) [@jmls](https://forums.suse.com/u/jmls)\
**Post date:** [June 10, 2016, 10:43am UTC](https://forums.suse.com/t/use-api-to-start-new-container-from-catalog/3084/1 "2016-06-10T10:43:54Z")

</div>

I have a catalog entry that I use to fire up new instances, with questions (user name etc)

is it possible to use the API to take a catalog entry, supply the answers to the questions and spin up the new container ?

I can’t seem to find an api for catalog entries in the documentation

thanks

---

<div class="post-metadata">

**Author:** ![jmls](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/jmls/32/1419_2.png) [@jmls](https://forums.suse.com/u/jmls)\
**Post date:** [June 21, 2016, 9:45am UTC](https://forums.suse.com/t/use-api-to-start-new-container-from-catalog/3084/2 "2016-06-21T09:45:54Z")

</div>

Bump… does anyone have any idea on how to take a catalog entry and spin up a stack from it ?

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [July 5, 2016, 10:40pm UTC](https://forums.suse.com/t/use-api-to-start-new-container-from-catalog/3084/3 "2016-07-05T22:40:57Z")

</div>

There is no “deploy this catalog entry” API call… the catalog API supplies compose yaml files, the UI generates a key/value map of answers, and those are passed to the standard create stack call (`environment` in the API…).

(Note: this is for Cattle orchestration… Kubernetes has different endpoints because it goes to the kubectl service directly)

[http://docs.rancher.com/rancher/latest/en/api/api-resources/environment/](http://docs.rancher.com/rancher/latest/en/api/api-resources/environment/)

Basically `POST /v1/projects/<projectId>/environments`

```auto
{
  name: "My App",
  dockerCompose: "your docker-compose yaml",
  rancherCompose: "your rancher-compose yaml",
  environment: {
    question1: "answer1",
    question2: "answer2"
  }
}

```

For double confusion, the answers go in the property called `environment`, because the substitution is intended for environment variables in libcompose.

---

<div class="post-metadata">

**Author:** ![zambon](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/zambon/32/2466_2.png) [@zambon](https://forums.suse.com/u/zambon)\
**Post date:** [July 8, 2016, 12:15am UTC](https://forums.suse.com/t/use-api-to-start-new-container-from-catalog/3084/4 "2016-07-08T00:15:42Z")

</div>

@vincent What are the following fields for in the context of `POST /v1/projects/<projectId>/environments`?

- `externald`
- `outputs`
- `previousEnvironments`
- `previousExternalId`

The docs page isn’t very clear about them. I’d be more than happy to contribute, if you could explain those to me. 🙂

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [July 8, 2016, 7:12pm UTC](https://forums.suse.com/t/use-api-to-start-new-container-from-catalog/3084/5 "2016-07-08T19:12:54Z")

</div>

`externalId` is an arbitrary string, but if it’s of the form `catalog://<the ID of a catalog template>` then it’s used by the UI to determine if upgrades to the stack from a new version of the catalog template are available.

`outputs` is for a feature that we didn’t really do anything with.

`previousEnvironments` and `previousExternalId` are not really meant to be set by you, but are used to store the previous enviornment map and external ID during an upgrade.

---

<div class="post-metadata">

**Author:** ![zambon](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/zambon/32/2466_2.png) [@zambon](https://forums.suse.com/u/zambon)\
**Post date:** [July 12, 2016, 2:56am UTC](https://forums.suse.com/t/use-api-to-start-new-container-from-catalog/3084/6 "2016-07-12T02:56:36Z")

</div>

Thanks for that! Pull request created. 🤘

---

<div class="post-metadata">

**Author:** ![bill](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/bill/32/6505_2.png) [@bill](https://forums.suse.com/u/bill)\
**Post date:** [July 12, 2016, 7:18am UTC](https://forums.suse.com/t/use-api-to-start-new-container-from-catalog/3084/7 "2016-07-12T07:18:47Z")

</div>

@vincent, @jmls

I found some API key as `http://<rancher_server>/v1-catalog`

seems it works.

---

<div class="post-metadata">

**Author:** ![mostafa](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/mostafa/32/1989_2.png) [@mostafa](https://forums.suse.com/u/mostafa)\
**Post date:** [January 5, 2017, 4:17am UTC](https://forums.suse.com/t/use-api-to-start-new-container-from-catalog/3084/8 "2017-01-05T04:17:35Z")

</div>

Whenever I try to POST the data i get the following:

```
{"id":"da2a00ba-3ac3-447a-9581-c9920a6a0588","type":"error","links":{},"actions":{},"status":422,"code":"InvalidFormat","message":null,"detail":null,"fieldName":"environment","baseType":"error"}

```

The data is like the following:

```
 {'environment': {u'public_port': 8035}, 'rancherCompose': u'.catalog:\n name: "Wordpress"\n version: "v0.1-educaas1"\n description: "Blog tool, publishing platform and CMS"\n uuid: Wordpress-0\n minimum_rancher_version: v0.51.0\n questions: \n - variable: public_port\n description: "public port to access the wordpress site"\n label: "Public Port"\n required: true\n default: "80"\n type: "int"\n\n\nwordpress:\n', 'name': 'API tester', 'dockerCompose': u'wordpress:\n image: wordpress\n links:\n - db:mysql\n ports:\n - ${public_port}:80\n\ndb:\n image: mariadb\n environment:\n MYSQL_ROOT_PASSWORD: example\n'}

```

What should I do ?

Note:  
When I checked the Audit Logs I noticed that Rancher got the request as follows:

```
    {
  "environment": "public_port",
  "name": "API tester",
  "rancherCompose": ".catalog:\n name: \"Wordpress\"\n version: \"v0.1-educaas1\"\n description: \"Blog tool, publishing platform and CMS\"\n uuid: Wordpress-0\n minimum_rancher_version: v0.51.0\n questions: \n - variable: public_port\n description: \"public port to access the wordpress site\"\n label: \"Public Port\"\n required: true\n default: \"80\"\n type: \"int\"\n\n\nwordpress:\n",
  "dockerCompose": "wordpress:\n image: wordpress\n links:\n - db:mysql\n ports:\n - ${public_port}:80\n\ndb:\n image: mariadb\n environment:\n MYSQL_ROOT_PASSWORD: example\n"
}

```

I have no idea why there is a different environment value as i sent it as a dictionary with key and value
