我有asp.net核心泊坞窗容器中,并与MySQL的容器。 现在我需要用asp.net核心容器等待mysql的容器,并准备(包括容器开始通过搬运工-compose.yml)。
喜欢的东西https://github.com/jwilder/dockerize ,wait-for-it.sh或等待换似乎并不为asp.net核心容器的工作。
有某人知道如何解决这个问题?
UPDATE
这是我的dockerfile:
FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore test.csproj
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out test.csproj
# Build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY ./entrypoint.sh ./app/
RUN chmod +x ./app/entrypoint.sh
CMD /bin/bash ./app/entrypoint.sh
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "test.dll"]
这是我的entrypoint.sh:
#!/bin/bash
set -e
run_cmd="dotnet run --server.urls http://*:80"
until dotnet ef database update; do
>&2 echo "SQL Server is starting up"
sleep 1
done
>&2 echo "SQL Server is up - executing command"
exec $run_cmd
如果我有搬运工人,撰写启动容器我得到的错误信息:
Unhandled Exception: System.FormatException: Value for switch '/app/entrypoint.sh' is missing.
test | at Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider.Load()
test | at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
test | at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
test | at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
test | at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
test | at test.Program.Main(String[] args) in /app/Program.cs:line 19
我怎样才能结合入口点,并在一个文件中CMD /斌/庆典./app/entrypoint.sh命令。 我想我需要的入口点为DOTNET applicatioin运行和CMD为entrypoint.sh等待数据库容器。 是否有解决方案同时获得运行?