Docker · Arazzo Workflow

Docker Stop and Remove a Container

Version 1.0.0

Find a container by name, stop it gracefully, wait for it to exit, and remove it with its anonymous volumes.

1 workflow 1 source API 1 provider
View Spec View on GitHub CloudContainersDevOpsInfrastructureMicroservicesArazzoWorkflows

Provider

docker

Workflows

stop-and-remove-container
Gracefully stop a container found by name and remove it once it has exited.
Resolves the container id from a name filter, stops the container with a grace period, waits on the not-running condition so removal cannot race the shutdown, and deletes the container.
4 steps inputs: containerName, removeVolumes, stopTimeout outputs: containerId, exitCode
1
findContainer
List containers including stopped ones, filtered to the supplied name, so the flow resolves a concrete container id before acting on it.
2
stopContainer
Send a graceful stop to the container. The daemon returns 204 when it stopped the container and 304 when it was already stopped, so both are acceptable outcomes for this step.
3
waitForExit
Block until the container reaches the not-running condition and capture the exit code, so removal cannot race a still-shutting-down container.
4
removeContainer
Remove the stopped container, optionally taking its anonymous volumes with it so the host is not left with orphaned data.

Source API Descriptions

Arazzo Workflow Specification

Raw ↑
arazzo: 1.0.1
info:
  title: Docker Stop and Remove a Container
  summary: Find a container by name, stop it gracefully, wait for it to exit, and remove it with its anonymous volumes.
  description: >-
    The teardown half of the container lifecycle. The workflow locates the
    container by name filter, issues a graceful stop with a timeout, blocks until
    the daemon reports the container has actually exited, and then removes it
    along with any anonymous volumes it created. Every step spells out its request
    inline so the flow can be read and executed without opening the underlying
    OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: containerApi
  url: ../openapi/docker-container-api-openapi.yml
  type: openapi
workflows:
- workflowId: stop-and-remove-container
  summary: Gracefully stop a container found by name and remove it once it has exited.
  description: >-
    Resolves the container id from a name filter, stops the container with a
    grace period, waits on the not-running condition so removal cannot race the
    shutdown, and deletes the container.
  inputs:
    type: object
    required:
    - containerName
    properties:
      containerName:
        type: string
        description: Name of the container to stop and remove.
      stopTimeout:
        type: integer
        description: Seconds to wait for a graceful stop before the daemon kills the container.
      removeVolumes:
        type: boolean
        description: Remove anonymous volumes associated with the container.
  steps:
  - stepId: findContainer
    description: >-
      List containers including stopped ones, filtered to the supplied name, so
      the flow resolves a concrete container id before acting on it.
    operationId: ContainerList
    parameters:
    - name: all
      in: query
      value: true
    - name: filters
      in: query
      value: '{"name": ["$inputs.containerName"]}'
    successCriteria:
    - condition: $statusCode == 200
    - context: $response.body
      condition: $.length > 0
      type: jsonpath
    outputs:
      containerId: $response.body#/0/Id
      currentState: $response.body#/0/State
  - stepId: stopContainer
    description: >-
      Send a graceful stop to the container. The daemon returns 204 when it
      stopped the container and 304 when it was already stopped, so both are
      acceptable outcomes for this step.
    operationId: ContainerStop
    parameters:
    - name: id
      in: path
      value: $steps.findContainer.outputs.containerId
    - name: t
      in: query
      value: $inputs.stopTimeout
    successCriteria:
    - condition: $statusCode == 204 || $statusCode == 304
  - stepId: waitForExit
    description: >-
      Block until the container reaches the not-running condition and capture the
      exit code, so removal cannot race a still-shutting-down container.
    operationId: ContainerWait
    parameters:
    - name: id
      in: path
      value: $steps.findContainer.outputs.containerId
    - name: condition
      in: query
      value: not-running
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      exitCode: $response.body#/StatusCode
      error: $response.body#/Error
  - stepId: removeContainer
    description: >-
      Remove the stopped container, optionally taking its anonymous volumes with
      it so the host is not left with orphaned data.
    operationId: ContainerDelete
    parameters:
    - name: id
      in: path
      value: $steps.findContainer.outputs.containerId
    - name: v
      in: query
      value: $inputs.removeVolumes
    - name: force
      in: query
      value: false
    successCriteria:
    - condition: $statusCode == 204
  outputs:
    containerId: $steps.findContainer.outputs.containerId
    exitCode: $steps.waitForExit.outputs.exitCode

Work with this as data

Every workflow here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for arazzo workflows

4 MCP tools reach this
  • find_arazzoBrowse and filter every workflow in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This workflow
curl "https://apis.io/api/v1/arazzo/docker-stop-and-remove-container-workflow"
All arazzo workflows
curl "https://apis.io/api/v1/arazzo?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.