Skip to main content

Create, update or delete Services or Volumes belonging to a Stack

PATCH/stacks/{stackId}/
v2
PATCH
container-update-stack

This command can be used to modify 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.

Managing volumes

You have two options for managing storage for your container stacks:

  • Explicitly declare volumes, using the $.volumes property of this request. Volumes are referenced by name, and can be mounted into the container by referencing them in the $.services[*].volumes property in the format <volume-name>:<mount-path>.
  • Use the project volume; this volume is shared among all managed apps and containers of a project. In order to mount the project volume, specify a file path instead of a volume name when mounting the volume (example /home/p-XXXXX/html:/var/html).

Request

  • stackIdstring (uuid)
    required

    ID of the Stack to create, update or delete Services or Volumes for.

Responses

application/json

OK

  • descriptionstring
    required
  • disabledboolean
    required
  • idstring (uuid)
    required
  • prefixstring
    required

    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
      • deployedStateobject
        required

        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
        • imagestring
          required

          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.

        • imageDigeststring
        • 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
          • ]
      • descriptionstring
        required
      • idstring (uuid)
        required
      • messagestring

        Message explaining the current state of the container. This may contain information about the current state of the container, or errors that occurred during deployment.

      • pendingStateobject
        required

        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
          • ]
        • 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
        • imagestring
          required

          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.

        • imageDigeststring
        • 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
          • ]
      • serviceNamestring
        required
      • shortIdstring
        required

        A short ID of the container. This is a unique identifier for the container within the project, and can be used to reference it in other API calls, or for SSH connections.

      • statusstring (one of: running, stopped, restarting, error, creating, starting)
        required
    • ]
  • volumesarray of object
    • Array[
    • *object
      • idstring (uuid)
        required
      • namestring
        required
      • orphanedboolean
        required

        Whether the Volume is attached to a Stack.

      • stackIdstring (uuid)
        required
      • storageUsageInBytesinteger
        required
      • storageUsageInBytesSetAtstring (date-time)
        required
    • ]

Usage examples

$ curl \
--fail \
--location \
-X PATCH \
-d '{"services":{"mysql":{"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:ro","/home/p-XXXXX/html:/var/www"]}},"volumes":{"data":{"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