compose icon indicating copy to clipboard operation
compose copied to clipboard

Add ability to use toml file instead of .env

Open deny-7 opened this issue 2 years ago • 1 comments

Description

It would be great to add the ability to use a toml file instead of a regular .env, because toml provides much more functionality than a regular .env.

e.g.

services:
  web:
    image: ${toml.services.images}
    ports: ${toml.services.ports}
    env_file: 
       - ${toml.services.env}
  redis:
    image: ${toml.services.images}

TOML example

[services]

[services.web]
image = "nginx"
ports = { 80 = 80, 443 = 443 }
env = {somevar1 = someval1, somevar2 = someval2}

[services.redis]
image = "redis"

deny-7 avatar May 09 '23 12:05 deny-7

That's an interesting proposal, some thoughts:

  • Compose would need to know about the current service node to resolve toml.services.images, this is a significant change in the parser
  • Your example assumes variable can be resolved into an array (see ports) which is also a major challenge (see https://github.com/docker/compose/issues/4249) we haven't addressed yet

ndeloof avatar May 10 '23 06:05 ndeloof

Closing as "not planned" While this is an interesting proposal, this would require a full redesign of the compose file parser For those interested in such a feature, better implement a compose file pre-processor you can combine with Docker Compose.

ndeloof avatar Jun 03 '25 12:06 ndeloof