Skip to content

env_file object format in compose.yaml causes error on Docker Compose < v2.24.0: 'env_file.0 must be a string #2

Description

@sidhant-shr

🚨 Issue: env_file.0 must be a string error on Docker Compose < v2.24.0

📋 Summary

The current compose.yaml uses the object-based syntax for the env_file section, which causes an error on Docker Compose versions older than v2.24.0. These versions only accept env_file as a string or a list of strings, not objects.


🧪 Steps to Reproduce

  1. Use Docker Compose CLI version older than v2.24.0
  2. Run the command:
    docker compose -f compose.yaml up -d

You will see the following error:

services.supra_cli.env_file.0 must be a string

💣 Problem Details

This snippet from compose.yaml:

env_file:
  - path: ./supra-cli.env
    required: false

is only supported on Docker Compose CLI v2.24.0 and above.

Older versions do not support the object format for env_file. They expect a string or list of strings, like this:

env_file:
  - ./supra-cli.env

✅ Universal Solution (Compatible with All Docker Compose Versions)

Change the env_file section in your compose.yaml to:

env_file:
  - ./supra-cli.env

This syntax works on all Docker Compose versions, including older ones.

🔧 Additional Information

  • Affected versions: Docker Compose CLI < v2.24.0
  • Root cause: Object-based env_file syntax introduced in v2.24.0
  • Impact: Prevents container startup on older Docker Compose versions
  • Solution: Use string-based syntax for backward compatibility

📚 References

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