Create, update or delete Services or Volumes belonging to a Stack
PATCH/stacks/ {stackId}/
Request
- stackIdstring (uuid)required
ID of the Stack to create, update or delete Services or Volumes for.
Responses
OK
- Schema-Dokumentation
- Beispiel
- JSON Schema
- descriptionstringrequired
- disabledbooleanrequired
- idstring (uuid)required
- prefixstringrequired
Prefix for all service-names in this stack.
- projectIdstring (uuid)required
- servicesarray of object
A set of containers that should be started in this stack. The key is relevant for network connectivity between containers, because you can use it as DNS name to resolve this containers from other containers running in the same project (or from managed apps running in the same project).
- Array[
- *object
- deployedStateobjectrequired
The actual state of the container that is currently deployed.
- commandarray of string
The container command (equivalent to the Docker cmd). When omitted, this defaults to the command defined in the image.
- Array[
- *string
]
- entrypointarray of string
The container entrypoint (equivalent to the Docker entrypoint). When omitted, this defaults to the entrypoint defined in the image.
- Array[
- *string
]
- envsobject
Key-value map of environment variables that should be passed into the container.
- *string
- imagestringrequired
The image to run, in the usual format also used by
docker run
anddocker compose
. When the image is pulled from a private registry, make sure to create it first, using thecontainer-create-registry
endpoint. The appropriate registry is matched by hostname. - portsarray of string
Exposed ports. Follows the format
<public-port>:<container-port>/<protocol>
. Exposed ports can be accessed from other containers (or managed apps) within the same project. To expose a port publicly, connect it with an ingress resource.- Array[
- *string
]
- volumesarray of string
Volume mounts for this container. These items always follow the format
<volume>:<mountpoint>
. The<volume>
may either be a named volume, or a file path in the (always present) project file system (which is shared among containers and managed apps within a project).- Array[
- *string
]
The desired state that is waiting to be reconciled.
- commandarray of string
The container command (equivalent to the Docker cmd). When omitted, this defaults to the command defined in the image.
- Array[
- *string
]
The container entrypoint (equivalent to the Docker entrypoint). When omitted, this defaults to the entrypoint defined in the image.
- Array[
- *string
Key-value map of environment variables that should be passed into the container.
- *string
The image to run, in the usual format also used by docker run
and docker compose
. When the image is pulled from a private registry, make sure to create it first, using the container-create-registry
endpoint. The appropriate registry is matched by hostname.
Exposed ports. Follows the format <public-port>:<container-port>/<protocol>
. Exposed ports can be accessed from other containers (or managed apps) within the same project. To expose a port publicly, connect it with an ingress resource.
- Array[
- *string
Volume mounts for this container. These items always follow the format <volume>:<mountpoint>
. The <volume>
may either be a named volume, or a file path in the (always present) project file system (which is shared among containers and managed apps within a project).
- Array[
- *string
- Array[
- *object
- idstring (uuid)required
- namestringrequired
- orphanedbooleanrequired
Whether the Volume is attached to a Stack.
- stackIdstring (uuid)required
- storageUsageInBytesintegerrequired
- storageUsageInBytesSetAtstring (date-time)required
{
"description": "string",
"disabled": true,
"id": "f0f86186-0a5a-45b2-aa33-502777496347",
"prefix": "string",
"projectId": "f0f86186-0a5a-45b2-aa33-502777496347",
"services": [
{
"deployedState": {
"command": [
"mysqld"
],
"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:8.0",
"ports": [
"3306:3306/tcp"
],
"volumes": [
"data:/var/lib/mysql",
"/home/p-XXXXX/html:/var/www"
]
},
"description": "MySQL DB",
"id": "f0f86186-0a5a-45b2-aa33-502777496347",
"pendingState": {
"command": [
"mysqld"
],
"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:8.0",
"ports": [
"3306:3306/tcp"
],
"volumes": [
"data:/var/lib/mysql",
"/home/p-XXXXX/html:/var/www"
]
},
"projectId": "f0f86186-0a5a-45b2-aa33-502777496347",
"serviceName": "mysql-db",
"stackId": "f0f86186-0a5a-45b2-aa33-502777496347",
"status": "running"
}
],
"volumes": [
{
"id": "f0f86186-0a5a-45b2-aa33-502777496347",
"name": "string",
"orphaned": true,
"stackId": "f0f86186-0a5a-45b2-aa33-502777496347",
"storageUsageInBytes": 123,
"storageUsageInBytesSetAt": "2024-12-19T00:33:15.022Z"
}
]
}
{
"properties": {
"description": {
"type": "string"
},
"disabled": {
"type": "boolean"
},
"id": {
"format": "uuid",
"type": "string"
},
"prefix": {
"description": "Prefix for all service-names in this stack.",
"type": "string"
},
"projectId": {
"format": "uuid",
"type": "string"
},
"services": {
"items": {
"properties": {
"deployedState": {
"description": "The actual state of the container that is currently deployed.\n",
"properties": {
"command": {
"items": {
"type": "string"
},
"type": "array",
"description": "The container command (equivalent to the [Docker cmd](https://docs.docker.com/reference/dockerfile/#cmd)). When omitted, this defaults to the command defined in the image.\n",
"example": [
"mysqld"
]
},
"entrypoint": {
"items": {
"type": "string"
},
"type": "array",
"description": "The container entrypoint (equivalent to the [Docker entrypoint](https://docs.docker.com/reference/dockerfile/#entrypoint)). When omitted, this defaults to the entrypoint defined in the image.\n",
"example": [
"docker-entrypoint.sh"
]
},
"envs": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"description": "Key-value map of environment variables that should be passed into the container.\n",
"example": {
"MYSQL_DATABASE": "my_db",
"MYSQL_PASSWORD": "my_password",
"MYSQL_ROOT_PASSWORD": "my_root_password",
"MYSQL_USER": "my_user"
}
},
"image": {
"type": "string",
"description": "The image to run, in the usual format also used by `docker run` and `docker compose`. When the image is pulled from a private registry, make sure to create it first, using the `container-create-registry` endpoint. The appropriate registry is matched by hostname.\n",
"example": "mysql:8.0"
},
"ports": {
"items": {
"type": "string"
},
"type": "array",
"description": "Exposed ports. Follows the format `<public-port>:<container-port>/<protocol>`. Exposed ports can be accessed from other containers (or managed apps) within the same project. To expose a port publicly, connect it with an ingress resource.\n",
"example": [
"3306:3306/tcp"
]
},
"volumes": {
"items": {
"type": "string"
},
"type": "array",
"description": "Volume mounts for this container. These items always follow the format `<volume>:<mountpoint>`. The `<volume>` may either be a named volume, or a file path in the (always present) project file system (which is shared among containers and managed apps within a project).\n",
"example": [
"data:/var/lib/mysql",
"/home/p-XXXXX/html:/var/www"
]
}
},
"required": [
"image"
],
"type": "object"
},
"description": {
"example": "MySQL DB",
"type": "string"
},
"id": {
"format": "uuid",
"type": "string"
},
"pendingState": {
"description": "The desired state that is waiting to be reconciled.\n",
"properties": {
"command": {
"items": {
"type": "string"
},
"type": "array",
"description": "The container command (equivalent to the [Docker cmd](https://docs.docker.com/reference/dockerfile/#cmd)). When omitted, this defaults to the command defined in the image.\n",
"example": [
"mysqld"
]
},
"entrypoint": {
"items": {
"type": "string"
},
"type": "array",
"description": "The container entrypoint (equivalent to the [Docker entrypoint](https://docs.docker.com/reference/dockerfile/#entrypoint)). When omitted, this defaults to the entrypoint defined in the image.\n",
"example": [
"docker-entrypoint.sh"
]
},
"envs": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"description": "Key-value map of environment variables that should be passed into the container.\n",
"example": {
"MYSQL_DATABASE": "my_db",
"MYSQL_PASSWORD": "my_password",
"MYSQL_ROOT_PASSWORD": "my_root_password",
"MYSQL_USER": "my_user"
}
},
"image": {
"type": "string",
"description": "The image to run, in the usual format also used by `docker run` and `docker compose`. When the image is pulled from a private registry, make sure to create it first, using the `container-create-registry` endpoint. The appropriate registry is matched by hostname.\n",
"example": "mysql:8.0"
},
"ports": {
"items": {
"type": "string"
},
"type": "array",
"description": "Exposed ports. Follows the format `<public-port>:<container-port>/<protocol>`. Exposed ports can be accessed from other containers (or managed apps) within the same project. To expose a port publicly, connect it with an ingress resource.\n",
"example": [
"3306:3306/tcp"
]
},
"volumes": {
"items": {
"type": "string"
},
"type": "array",
"description": "Volume mounts for this container. These items always follow the format `<volume>:<mountpoint>`. The `<volume>` may either be a named volume, or a file path in the (always present) project file system (which is shared among containers and managed apps within a project).\n",
"example": [
"data:/var/lib/mysql",
"/home/p-XXXXX/html:/var/www"
]
}
},
"required": [
"image"
],
"type": "object"
},
"projectId": {
"format": "uuid",
"type": "string"
},
"serviceName": {
"example": "mysql-db",
"type": "string"
},
"stackId": {
"format": "uuid",
"type": "string"
},
"status": {
"enum": [
"running",
"stopped",
"restarting",
"error",
"creating",
"starting"
],
"type": "string"
}
},
"required": [
"id",
"stackId",
"projectId",
"description",
"serviceName",
"pendingState",
"deployedState",
"status"
],
"type": "object"
},
"type": "array",
"description": "A set of containers that should be started in this stack. The key is relevant for network connectivity between containers, because you can use it as DNS name to resolve this containers from other containers running in the same project (or from managed apps running in the same project).\n",
"x-example-key": "mysql"
},
"volumes": {
"items": {
"properties": {
"id": {
"format": "uuid",
"type": "string"
},
"name": {
"type": "string"
},
"orphaned": {
"description": "Whether the Volume is attached to a Stack.",
"type": "boolean"
},
"stackId": {
"format": "uuid",
"type": "string"
},
"storageUsageInBytes": {
"type": "integer"
},
"storageUsageInBytesSetAt": {
"format": "date-time",
"type": "string"
}
},
"required": [
"id",
"stackId",
"name",
"orphaned",
"storageUsageInBytes",
"storageUsageInBytesSetAt"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"id",
"projectId",
"description",
"disabled",
"prefix"
],
"type": "object"
}
Usage examples
- cURL
- JavaScript SDK
- PHP SDK
$ curl \
--fail \
--location \
-X PATCH \
-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.updateStack({
"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\UpdateStack\UpdateStackRequest;
use \Mittwald\ApiClient\Generated\V2\Clients\Container\UpdateStack\UpdateStackRequestBody;
$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));
// TODO: Please consult the properties and constructor signature of
// UpdateStackRequestBody to learn how to construct a valid instance
$body = new UpdateStackRequestBody(/* TODO: ... */);
$request = (new UpdateStackRequest(
stackId: "f0f86186-0a5a-45b2-aa33-502777496347",
body: $body
));
$response = $client->container()->updateStack($request);
var_dump($response->getBody();