2

I'm trying to add an Azure Function project to a docker-compose file created in Visual Studio 2019 (16.7.6), but this causes the solution to fail to build.

(Docker for Windows 2.4.0.0 (48506), with WSL2 support enabled, running in Linux container mode on Windows 10 Pro 2004)

Steps to reproduce:

  1. Create a new solution with a Web Api project 'Web' that includes docker support.
  2. Add a new Azure Function project 'Func' with an Http trigger function and then added docker support via Visual Studio Add > Docker Support option.
  3. Add 'Container Orchestration Support' to Web project to generate a docker-compose.yml file that has the web app

At this point the solution builds debugging works for the web or func app in docker or docker-compose - all good.

When 'Func' project is added manually to docker-compose.yml the solution no longer builds:

CTC1031 Linux containers are not supported for Func project
Project: docker-compose
File: Microsoft.VisualStudio.Docker.Compose.targets
Line 303

However, I can run docker-compose fine from the command line:

docker-compose -f docker-compose.yml up

and both Web and Func app start up fine.

My docker-compose.yml file is

version: '3.4'

services:
  web:
    image: ${DOCKER_REGISTRY-}web
    build:
      context: .
      dockerfile: Web/Dockerfile

  func:
    image: ${DOCKER_REGISTRY-}func
    build:
      context: .
      dockerfile: Func/Dockerfile

Any ideas why I get the above error when building the solution in Visual Studio?

MarkdotH
  • 353
  • 1
  • 2
  • 9

3 Answers3

1

Have the same issue. It seems that docker-compose project type allows to set up dependencies only to specific type of projects, like Sdk="Microsoft.NET.Sdk.Web", and does not allow to library projects like Sdk="Microsoft.NET.Sdk". Referencing Dockerfile from docker-compose.yml automatically sets up reference.

In case of wrong project type compose works, but compilation of docker-compose project fails.

1

I had the same problem creating an Azure Function on Docker in Visual Studio 2022 and updating Visual Studio 2022 to the latest version (version above 17.5) helped.

Earlier I had the message "CTC1031 Linux containers are not supported for Func project" and I tried to replace the function with Azure Function Isolated instead of InProcess, but it turned out to be unnecessary.

0

I got the error as well:

CTC1031 Linux containers are not supported for

It probably means that your Output type for the project is set to Class Library instead of Console Application.

enter image description here

Ogglas
  • 62,132
  • 37
  • 328
  • 418