Skip to content

P0: ECS multi-container tracking bug — only last container tracked/stopped #656

Closed

Description

@agbishop

Summary

The ECS containers map uses task.TaskArn as key, but tasks with multiple containers share the same key. Only the last container created is tracked. StopTask() only stops the last container — all others are leaked.

Additionally:

  • Docker container leak on error: If container creation succeeds but ContainerStart() fails, the container is never removed
  • No cascade cleanup on cluster deletion: Docker containers continue running after ECS cluster deletion

Impact

P0 — Resource leak. Multi-container tasks leak Docker containers.

Fix

  • Use composite key (TaskArn + container name) or store slice of container IDs per task
  • Add error-path cleanup for failed container starts
  • Cascade container stops on cluster deletion

Files

  • services/ecs/docker_runner.go
  • services/ecs/backend.go

Activity

  1. agbishop commented on Mar 15, 2026

    @agbishop
    CollaboratorAuthor

    copilot-autodev: agent task created for issue #656 (initial invoke).

  2. agbishop commented on Mar 15, 2026

    @agbishop
    CollaboratorAuthor

    copilot-autodev: Tracking PR #795 for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions