【问题标题】:can't find a suitable configuration file in this directory or any docker compose (docker-compose section not getting added in solution)在此目录或任何 docker compose 中找不到合适的配置文件(解决方案中未添加 docker-compose 部分)
【发布时间】:2019-02-12 22:19:55
【问题描述】:

我已经在我的 windows (10) 上安装了 docker,当我尝试构建一个新项目时,我总是收到以下错误:

Can't find a suitable configuration file in this directory or any
    parent. Are you in the right directory?

    Supported filenames: docker-compose.yml, docker-compose.yaml

当我检查我在 Visual Studio 2017 中创建的项目时,我没有在解决方案中看到 docker-compose 部分。它只有一个项目(.Net core 2.0)和一个 Dockerfile 文件。

以下是我遵循的步骤。

文件->新建项目->Asp.Net核心网络应用->API(启用Docker支持)->确定

这就是我的项目结构的样子(其中没有 docker-compose 部分)

我这里有什么遗漏吗?

【问题讨论】:

  • 这个问题似乎更多是关于visual studio 2017而不是docker,
  • 甚至怀疑这一点。但我不确定我缺少什么(在 VS 或 Docker 中)。所以在这里寻求帮助
  • 日志信息清楚地表明您没有docker-compose 文件,您是否尝试在项目目录中添加docker-compose.yml。 .?
  • 我是否必须为您创建的每个解决方案手动创建它?由于我在创建项目时选择了 Docker Support,因此应该添加该文件

标签: docker asp.net-core docker-compose dockerfile asp.net-core-2.0


【解决方案1】:

不是真正的 VS 2017 专家,但您需要在项目内创建一个 docker-compose.yml 文件。

更多信息可以在here找到。

version: '3.5'
services:
  client:
    container_name: WebApplication 
    build:
      dockerfile: Dockerfile
    volumes:
        # Any volumes you would mount goes here
    ports:
        # Ports that need to be mapped from container to host goes here
    environment:
        # Any environment variables

编辑:为了让 VS 2017 自动创建 docker-compose.yml,您需要右键单击项目并选择添加 > Orchestrator Support(15.8 和更高版本)或添加 > Docker 项目支持(15.8以下)。

【讨论】:

  • 我是否必须为您创建的每个解决方案手动创建它?因为我在创建项目时选择了 Docker 支持,所以应该添加该文件
  • 看起来您可以右键单击您的应用程序并选择“添加”>“Docker 项目支持”来为您生成文件。
  • 嗨,安东尼。谢谢回复。我什至尝试过,但它只是重新创建了 Dockerfile,但没有添加 docker-compose (yaml/yml) 文件
  • 你有什么版本的VS 2017?对于 15.8 或更高版本,您需要执行 Add > Container Orchestrator Support
  • 已编辑答案:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-01-30
  • 1970-01-01
  • 1970-01-01
  • 2021-10-13
  • 2022-01-14
相关资源
最近更新 更多