Multiple core versions in single docker

For now I have 3.1.8 in my docker(my first project works on it). I add second project with diffrent version, its 2.1.0, its not possible for me to change it from project side. When I use some function from last added project I got this error:

The framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
  - The following frameworks were found:
      3.1.8 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Its possible to add second version 2.1.0 to docker?

This is hierarchy in my docker file. I want to add version 2.1.0 here:
enter image description here


FROM AS base

EXPOSE 44399 443
FROM AS build
COPY ["Project1.Api/Project1.Api.csproj", "Project1.Api/"]
COPY ["Project2.Test/Project2.Test.csproj", "Project1.Test/"]
RUN dotnet restore "Project1.Api/Project1.Api.csproj"
COPY . .
WORKDIR "/src/Project1.Api"
RUN dotnet build "Project1.Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Project1.Api.csproj" -c Release -o /app/publish
FROM base AS final
ENV ASPNETCORE_URLS http://*:44399
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Project1.Api.dll"]

Source: Docker Questions