У меня есть файл Docker, например
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["GoldHouse.csproj", "/"]
RUN dotnet restore "/GoldHouse.csproj"
COPY . .
WORKDIR "/src/"
RUN dotnet build "GoldHouse.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "GoldHouse.csproj" -c Release -o /app
COPY "wait-for-it.sh" "/app/wait-for-it.sh"
COPY "wait-for-it-mysql.sh" "/app/wait-for-it-mysql.sh"
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
#ENTRYPOINT ["dotnet", "GoldHouse.dll"]
RUN chmod +x /app/wait-for-it-mysql.sh
и docker-compose.yml
, как
version: '3'
services:
db:
image: mysql
restart: always
container_name: goldhouse-db
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: goldhouse
MYSQL_PASSWORD: goldhouse
MYSQL_DATABASE: goldhouse
command: ["echo", "mysql is ready"]
web:
# image: edward8520/goldhouse
container_name: goldhouse-web
build:
context: .
dockerfile: Dockerfile
ports:
- "5000:80"
depends_on:
- "db"
# command: ["echo", "goldhouse is ready"]
command : ["./wait-for-it-mysql.sh"]
# command: ["./wait-for-it.sh", "db:33060", "--", "echo", "mysql is ready", "dotnet", "GoldHouse.dll"]
. Для целей тестирования я использовал wait-for-it-mysql.sh
, как
#!/bin/bash
echo "Test"
Это исключение
D:\Edward\SourceCode\GoldHouse\GoldHouse>docker-compose up
goldhouse-db is up-to-date
Recreating goldhouse-web ... done
Attaching to goldhouse-db, goldhouse-web
goldhouse-web | standard_init_linux.go:207: exec user process caused "no such file or directory"