@@ -58,7 +58,7 @@ def build(
5858 full_cmd += services
5959 run (full_cmd , capture_stdout = False )
6060
61- def config (self , return_json : bool = False ) -> Union [ComposeConfig , Dict [str , Any ]]:
61+ def config (self , return_json : bool = False , envs : Dict [ str , str ] = {} ) -> Union [ComposeConfig , Dict [str , Any ]]:
6262 """Returns the configuration of the compose stack for further inspection.
6363
6464 For example
@@ -76,12 +76,13 @@ def config(self, return_json: bool = False) -> Union[ComposeConfig, Dict[str, An
7676 lists and dicts corresponding to the json response, unmodified.
7777 It may be useful if you just want to print the config or want to access
7878 a field that was not in the `ComposeConfig` class.
79+ envs: A dictionary of environment variables to set for the compose process.
7980
8081 # Returns
8182 A `ComposeConfig` object if `return_json` is `False`, and a `dict` otherwise.
8283 """
8384 full_cmd = self .docker_compose_cmd + ["config" , "--format" , "json" ]
84- result = run (full_cmd , capture_stdout = True )
85+ result = run (full_cmd , capture_stdout = True , env = envs )
8586 if return_json :
8687 return json .loads (result )
8788 else :
@@ -651,6 +652,7 @@ def up(
651652 log_prefix : bool = True ,
652653 start : bool = True ,
653654 quiet : bool = False ,
655+ envs : Dict [str , str ] = {},
654656 ):
655657 """Start the containers.
656658
@@ -681,6 +683,7 @@ def up(
681683 start: Start the service after creating them.
682684 quiet: By default, some progress bars and logs are sent to stderr and stdout.
683685 Set `quiet=True` to avoid having any output.
686+ envs: A dictionary of environment variables to set for the compose process.
684687
685688 # Returns
686689 `None` at the moment. The plan is to be able to capture and stream the logs later.
@@ -706,7 +709,7 @@ def up(
706709 services = to_list (services )
707710 full_cmd += services
708711 # important information is written to both stdout AND stderr.
709- run (full_cmd , capture_stdout = quiet , capture_stderr = quiet )
712+ run (full_cmd , capture_stdout = quiet , capture_stderr = quiet , env = envs )
710713
711714 def version (self ) -> str :
712715 """Returns the version of docker compose as a `str`."""
0 commit comments