Error: Docker Compose job returns exit code 0 despite container failure in Automic
search cancel

Error: Docker Compose job returns exit code 0 despite container failure in Automic

book

Article ID: 445574

calendar_today

Updated On:

Products

CA Automic Workload Automation - Automation Engine

Issue/Introduction

When executing a Unix job that runs Docker Compose, the Automic Agent reports a successful completion (Return Code 0) even if a specific container within the Docker environment fails with an exit code (e.g., RC 1). This behavior prevents the Automation Engine from detecting internal application failures within the Docker stack.

 

Symptoms

  • The Automic Job Messenger reports RET-CODE: 0 in the job report.
  • The internal Docker container logs show a failure (e.g., exited with code 1).
  • Subsequent dependent jobs in a Workflow or Job Plan trigger prematurely because the job is marked as ENDED_OK.

Environment

  • Product: Automic Workload Automation
  • Agent: Unix / Linux Agent
  • Third-Party: Docker Compose (all versions)

Cause

By default, the command docker compose up returns the exit code of the Docker Compose orchestrator itself, which is typically 0 if the environment was successfully built and started. It does not automatically pass through the exit code of individual service containers to the shell/agent.

Resolution

To ensure the Automic Agent captures the failure of a specific container, use the --exit-code-from flag in the job script. This flag forces the docker compose command to return the exit code of the specified service container.

  1. Identify the service name in the docker-compose.yml file that contains the critical process.
  2. Modify the job command in the Automic Job object to the following format:
    docker compose up --exit-code-from <service_name>
  3. Save the job and execute a test run.

Example: If the service is named app-backend, the command should be:

docker compose up --exit-code-from app-backend