Visual Studio 2017 Docker工具:自定义Entrypoint被自动生成文件覆盖的解决方法
I've run into this exact headache with Visual Studio 2017's Docker tooling before—those auto-generated docker-compose.vs.release.g.yml (and similar) files are frustrating when you're trying to set a custom entrypoint. Here's how to resolve it without wasting time fighting VS's auto-generation:
Why This Happens
VS automatically spits out these .g.yml files to inject debugging and startup logic. When it runs Docker Compose, it loads these files after your docker-compose.override.yml. Since Compose applies configurations in the order files are loaded, later settings overwrite earlier ones—so VS's entrypoint clobbers your custom one. And forget editing the .g.yml files directly; any manual changes get wiped out on the next build or run.
Solutions
1. Reorder Compose File Loading (Recommended)
The simplest fix is to adjust the load order so your custom entrypoint gets applied last:
- Right-click your Docker Compose project in Solution Explorer → Properties
- Navigate to the Debug tab
- Find the Docker Compose Command Line field
- By default, it’ll look something like this:
docker-compose -f "docker-compose.yml" -f "docker-compose.override.yml" -f "docker-compose.vs.release.g.yml" up -d - Rearrange the file paths to put your override file after VS's auto-generated one:
docker-compose -f "docker-compose.yml" -f "docker-compose.vs.release.g.yml" -f "docker-compose.override.yml" up -d - Save the changes. Now your custom entrypoint from
docker-compose.override.ymlwill take precedence over VS's injected configuration.
2. Use a Separate Custom Compose File
If you prefer not to mess with the override file's order, create a new file (e.g., docker-compose.custom.yml) with your entrypoint settings, then add it to the end of the command line in the Debug properties:
docker-compose -f "docker-compose.yml" -f "docker-compose.override.yml" -f "docker-compose.vs.release.g.yml" -f "docker-compose.custom.yml" up -d
This guarantees your custom config is applied last, no matter the order of other files.
3. Disable Debugger Injection (If You Don’t Need Container Debugging)
If you don’t need to debug your app inside the container, you can turn off VS's debugging injection entirely:
- Right-click your web/app project → Properties
- Go to the Debug tab
- Under the Docker section, uncheck the option for Enable Docker Debugging (label may vary slightly)
- This stops VS from generating entrypoint settings in the
.g.ymlfiles, so your custom entrypoint won’t be overridden at all.
内容的提问来源于stack exchange,提问作者Eric

