Declaratively create, update or delete Services or Volumes belonging to a Stack
PUT/stacks/ {stackId}/
v2
PUT
container-declare-stack
This command can be used to declare the desired state of a container stack.
Usage
Obtaining the default stack
Every mStudio project comes with a default stack named default
. You can obtain the default stack by using the unknown operation container-list-stack
operation.
Creating new stacks
Creating new stacks is not supported at this time. You can only manage the default
stack.
Request
Responses
Usage examples
- cURL
- JavaScript SDK
- PHP SDK
$ curl \
--fail \
--location \
-X PUT \
-d '{"services":{"string":{"command":["mysqld"],"description":"MySQL DB","entrypoint":["docker-entrypoint.sh"],"envs":{"MYSQL_DATABASE":"my_db","MYSQL_PASSWORD":"my_password","MYSQL_ROOT_PASSWORD":"my_root_password","MYSQL_USER":"my_user"},"image":"mysql","ports":["3306:3306/tcp"],"volumes":["data:/var/lib/mysql"]}},"volumes":{"string":{"name":"mysql-volume"}}}' \
-H "Authorization: Bearer $MITTWALD_API_TOKEN" \
-H 'Content-Type: application/json' \
https://api.mittwald.de/v2/stacks/f0f86186-0a5a-45b2-aa33-502777496347
import { MittwaldAPIV2Client } from "@mittwald/api-client";
import { assertStatus } from "@mittwald/api-client-commons";
const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
const response = await client.container.declareStack({
"stackId": "f0f86186-0a5a-45b2-aa33-502777496347",
"data": {
"services": {
"string": {
"command": [
"mysqld"
],
"description": "MySQL DB",
"entrypoint": [
"docker-entrypoint.sh"
],
"envs": {
"MYSQL_DATABASE": "my_db",
"MYSQL_PASSWORD": "my_password",
"MYSQL_ROOT_PASSWORD": "my_root_password",
"MYSQL_USER": "my_user"
},
"image": "mysql",
"ports": [
"3306:3306/tcp"
],
"volumes": [
"data:/var/lib/mysql"
]
}
},
"volumes": {
"string": {
"name": "mysql-volume"
}
}
}
});
assertStatus(response, 200);
use \Mittwald\ApiClient\Generated\V2\Clients\Container\DeclareStack\DeclareStackRequest;
use \Mittwald\ApiClient\Generated\V2\Clients\Container\DeclareStack\DeclareStackRequestBody;
$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));
// TODO: Please consult the properties and constructor signature of
// DeclareStackRequestBody to learn how to construct a valid instance
$body = new DeclareStackRequestBody(/* TODO: ... */);
$request = (new DeclareStackRequest(
stackId: "f0f86186-0a5a-45b2-aa33-502777496347",
body: $body
));
$response = $client->container()->declareStack($request);
var_dump($response->getBody();