@@ -58,7 +58,9 @@ 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 (
62+ self , return_json : bool = False , envs : Dict [str , str ] = {}
63+ ) -> Union [ComposeConfig , Dict [str , Any ]]:
6264 """Returns the configuration of the compose stack for further inspection.
6365
6466 For example
@@ -76,12 +78,13 @@ def config(self, return_json: bool = False) -> Union[ComposeConfig, Dict[str, An
7678 lists and dicts corresponding to the json response, unmodified.
7779 It may be useful if you just want to print the config or want to access
7880 a field that was not in the `ComposeConfig` class.
81+ envs: A dictionary of environment variables to set for the compose process.
7982
8083 # Returns
8184 A `ComposeConfig` object if `return_json` is `False`, and a `dict` otherwise.
8285 """
8386 full_cmd = self .docker_compose_cmd + ["config" , "--format" , "json" ]
84- result = run (full_cmd , capture_stdout = True )
87+ result = run (full_cmd , capture_stdout = True , env = envs )
8588 if return_json :
8689 return json .loads (result )
8790 else :
@@ -651,6 +654,7 @@ def up(
651654 log_prefix : bool = True ,
652655 start : bool = True ,
653656 quiet : bool = False ,
657+ envs : Dict [str , str ] = {},
654658 ):
655659 """Start the containers.
656660
@@ -681,6 +685,7 @@ def up(
681685 start: Start the service after creating them.
682686 quiet: By default, some progress bars and logs are sent to stderr and stdout.
683687 Set `quiet=True` to avoid having any output.
688+ envs: A dictionary of environment variables to set for the compose process.
684689
685690 # Returns
686691 `None` at the moment. The plan is to be able to capture and stream the logs later.
@@ -706,7 +711,7 @@ def up(
706711 services = to_list (services )
707712 full_cmd += services
708713 # important information is written to both stdout AND stderr.
709- run (full_cmd , capture_stdout = quiet , capture_stderr = quiet )
714+ run (full_cmd , capture_stdout = quiet , capture_stderr = quiet , env = envs )
710715
711716 def version (self ) -> str :
712717 """Returns the version of docker compose as a `str`."""
0 commit comments