Skip to content

[Bug]: Compose.yaml variable substitution ignored when target arg exists in environment (even if empty) #7506

@kmaid

Description

@kmaid

Error Message and Logs

Summary
When using compose.yaml to map Coolify's SERVICE_URL_* to a custom arg name, the substitution fails if that arg name exists in Coolify's environment variables. Coolify's --build-arg passes the empty value, overriding the substitution. The variable cannot be deleted due to "Please remove it from the Docker Compose file first" error.

Steps to Reproduce

  1. compose.yaml - Map Coolify's auto-generated URL to app's expected variable:
    services: app: build: args: - MY_URL=${SERVICE_URL_APP}
  2. Coolify environment contains:
    SERVICE_URL_APP=https://generated.example.com # Auto-generated ✅MY_URL= # Previously defined, now empty
  3. Try to delete MY_URL:

❌ Cannot delete environment variable 'MY_URL'
Please remove it from the Docker Compose file first.

  1. Build runs with:
    docker compose --env-file build-time.env --build-arg MY_URL --build-arg SERVICE_URL_APP ...
  2. Dockerfile receives:
    MY_URL='' # ❌ Empty - substitution ignoredSERVICE_URL_APP='https://generated.example.com' # ✅ Exists
    Expected
    MY_URL receives https://generated.example.com from ${SERVICE_URL_APP}
    OR allow deletion of MY_URL since ${MY_URL} isn't in compose.yaml
    Actual
    MY_URL is empty
    Cannot delete MY_URL
    User is stuck

Example Repository URL

No response

Coolify Version

v4.0.0-beta.452

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔍 TriageIssues that need assessment and prioritization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions