You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ability to pass --env-file argument in docker-compose #273
The issue I'm having is I can't see a way to pass a custom env-file in Visual Studio when debugging my docker-compose project. I can see there is a DockerfileRunEnvironmentFiles property that allows doing this for single projects (docker run) but there is nothing similar for docker-compose. Furthermore, I can't find a documented way to pass any custom options that come after docker-compose before the commands which would take care of this (e.g. docker-compose --env-file my_vars -f docker-compose-custom.yml up).
Are there any options to accomplish this? Can I customise how the docker-compose command gets built?
Hi @tthordarson ,
Additional arguments to the docker-compose up command can be passed through DockerComposeUpArguments property.
That being said, I tried --env-file with DockerComposeUpArguments, but --env-file needs to be passed before up as opposed to after up.
I am investigating how this could be achieved.
Sorry for the delay, this has now reached the top of the backlog and a fix is out for review. I still don't have a timeline for when the fix will be available, but it is in progress.
Thanks Nathan Carlson (@NCarlsonMSFT) Test on visual studio 2022 preview 4 but still getting the same message unknown flag: --env-file adding this <DockerComposeBuildArguments>--env-file .env</DockerComposeBuildArguments>
Sorry Raúl Flores (@raulidavid), I was flitting through too many things yesterday and omitted telling you that there is a new MSBuildProperty to support this: <DockerComposeEnvFilePath>myawesomefilename.env</DockerComposeEnvFilePath>
Reacted by Vinicius Andrade
Reacted by Raúl Flores
Reacted by ubbeK, Anton Shakalo, Jon Grant and Vinicius Andrade
Activity
pratiksanglikar commentedon Sep 24, 2020
Hi @tthordarson ,
Additional arguments to the
docker-compose upcommand can be passed throughDockerComposeUpArgumentsproperty.That being said, I tried
--env-filewithDockerComposeUpArguments, but--env-fileneeds to be passed beforeupas opposed to afterup.I am investigating how this could be achieved.
syedhassaanahmed commentedon Jun 18, 2021
Pratik Sanglikar (@pratiksanglikar) Any update on the investigation about passing the custom env file as argument to
docker compose up?pratiksanglikar commentedon Jun 22, 2021
Hassaan Ahmed (@syedhassaanahmed), it is an item on our backlog, but with the current priorities, there is no specific date when we can get to it.
CriggerMarg commentedon Aug 12, 2022
Pratik Sanglikar (@pratiksanglikar) Any updates now?
NCarlsonMSFT commentedon Aug 15, 2022
Anton Shakalo (@CriggerMarg) this remains on the backlog (now assigned to me) and is actually getting fairly close to the top.
ludovicasa commentedon Dec 14, 2022
Hello,
any news on this one ?
Currently the command generated by VS adds the "--env-file" option after the "up" command:
up -d --env-file .env.devresulting in an error:
Maybe there is a workaround ?
NCarlsonMSFT commentedon Dec 14, 2022
Sorry for the delay, this has now reached the top of the backlog and a fix is out for review. I still don't have a timeline for when the fix will be available, but it is in progress.
raulidavid commentedon Jan 28, 2023
Please, friend Nathan Carlson (@NCarlsonMSFT) , let me know when it's ready. I'm having the same problem. Regards
NCarlsonMSFT commentedon Jan 31, 2023
Raúl Flores (@raulidavid) this currently available in the preview channel 17.5 Preview 4
raulidavid commentedon Jan 31, 2023
Thanks Nathan Carlson (@NCarlsonMSFT) Test on visual studio 2022 preview 4 but still getting the same message unknown flag: --env-file adding this
<DockerComposeBuildArguments>--env-file .env</DockerComposeBuildArguments>NCarlsonMSFT commentedon Jan 31, 2023
Sorry Raúl Flores (@raulidavid), I was flitting through too many things yesterday and omitted telling you that there is a new MSBuildProperty to support this:
<DockerComposeEnvFilePath>myawesomefilename.env</DockerComposeEnvFilePath>raulidavid commentedon Feb 1, 2023
thanks Nathan Carlson (@NCarlsonMSFT) now it's working!!
CriggerMarg commentedon Feb 6, 2023
Nathan Carlson (@NCarlsonMSFT) how about updating documentation https://learn.microsoft.com/en-us/visualstudio/containers/docker-compose-properties ?
NCarlsonMSFT commentedon Feb 6, 2023
Anton Shakalo (@CriggerMarg) I've added updating the docs to the backlog.
davhdavh commentedon May 5, 2023
It works great, but would be nice if it was also documented :)
fiveisprime commentedon Jun 21, 2024
Closing this as fixed. The documentation has also been updated to include the
DockerComposeEnvFilePathproperty