无法从Docker容器连接到Mongo DB Cloud Atlas实例

时间:2019-11-21 20:44:32

标签: c# mongodb docker .net-core mongodb-atlas

我有一个使用Scram方法的.Net Core 3.0应用程序,可以在运行时毫无问题地连接到Mongo DB Cloud Atlas实例。但是,当我尝试在Docker容器中运行应用程序时出现以下错误。

错误:

"Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1."

这是我的Dockerfile:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS base
WORKDIR /app

EXPOSE 80

EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build

WORKDIR /src

COPY ["ShortUrl.API/ShortUrl.API.csproj", "ShortUrl.API/"]

RUN dotnet restore "ShortUrl.API/ShortUrl.API.csproj"

COPY . .

RUN dotnet build "ShortUrl.API.csproj" -c Release -o /app/build


FROM build AS publish
RUN dotnet publish "ShortUrl.API.csproj" -c Release -o /app/publish

FROM base AS final

WORKDIR /app

COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "ShortUrl.API.dll"]

以下是我正在构建和运行容器的命令。

docker build -t urlshortenerservice:v3 .

docker run -it -p 5500:80  urlshortenerservice:v3

0 个答案:

没有答案