Create a Container

Creates a new container.

Requires the containers-deploy permission.

query
  • include

    Accepted Values: creatorsimagesstack_buildsstacksenvironments

  • meta

    Accepted Values: instance_countsdomaindomainsips

Arguments
  • name
    string

    The name of the new container.

  • environment_id
    string

    The ID of the environment the container will be a part of.

  • image_id
    string

    The ID of the image that's being used to create the container.

  • stateful
    bool

    When set to true, the container will be set to "stateful". When false it will be set to stateless.

  • config
    object

    A container configuration, the same as the config section found in the stack spec.

    Show child fields
  • volumes
    array of objects
    optional

    An array of volume configuration settings as objects.

    Show child fields
  • annotations
    object
    optional

    A key value store of custom data for your container. Not used by the platform internally.

Returns

Returns a container resource (the one you just created), otherwise returns an Error.

POST /v1/containers

Example Request
$ curl https://api.cycle.io/v1/containers \
-H
"Authorization: Bearer API_KEY"
\
-H
"X-HUB-ID: HUB_ID"
\
-H 'Content-Type: application/json' \
-d '{"name":"Demo Name","stateful":true,"environment_id":"5b9c2a77b6393d0001eb45fd","image_id":"5cf4c971b894940001b730a3","config":{"network":{"public":"enable","hostname":"test-container","ports":["9000:3000"]},"deploy":{"instances":1,"constraints":{"node":{"tags":{"any":[],"all":[]}},"secrets":[],"containers":[]}},"integrations":{"lets_encrypt":{"enable":false}}},"volumes":[{"read_only":false,"local":{"max_size":"15G"},"destination":"/var/lib/myvol","remote_access":{"enable":true,"password":{"algorithm":"sha512","data":"409F8974D7A7C2189B52574E2AD31A5EFE3E0E0AE4D8E71F0EC3C7CDCB328C84D59B2F8C78B03D1A200566E0BBDB884E522DE4EC5DC3E8CA59D7FDF4D16E6AD6"}}}]}' \
-X POST
Example Response
{
"data": {
"id": "5b9c2a77b6393d0001eb45fd",
"name": "Demo Name",
"identifier": "demo-container",
"creator": {
"id": "5b9c2a77b6393d0001eb45fd",
"type": "account"
},
"environment": {
"id": "5b9c2a77b6393d0001eb45fd",
"cluster": "production",
"container_subnet": "01d6",
"ipv6": {
"ip": "fd00::452a:d6:0:0",
"cidr": "fd00::452a:d6:0:0/96"
},
"legacy": {
"subnet": 221,
"ipv4": {
"ip": "10.222.221.0",
"cidr": "10.222.221.0/16"
}
}
},
"hub_id": "5b9c2a77b6393d0001eb45fd",
"image": {
"id": "5cf4c971b894940001b730a3",
"service": null
},
"config": {
"network": {
"public": "enable",
"hostname": "test-container",
"ports": [
"9000:3000"
]
},
"deploy": {
"instances": 1,
"constraints": {
"node": {
"tags": {
"any": [],
"all": []
}
},
"secrets": [],
"containers": []
}
},
"integrations": {
"lets_encrypt": {
"enable": false
}
}
},
"instances": 1,
"annotations": {},
"stateful": false,
"role": null,
"deprecate": false,
"state": {
"changed": "2019-06-18T04:49:55.336Z",
"current": "running",
"desired": "running"
},
"events": {
"created": "2019-06-03T07:17:20.411Z",
"updated": "0001-01-01T00:00:00Z",
"deleted": "0001-01-01T00:00:00Z",
"started": "0001-01-01T00:00:00Z"
}
}
}