我的代码和文件如下。使用“ docker-compose up --build”命令运行后,显示错误
ERROR: for mssql Cannot create container for service mssql: invalid volume specification: 'C:\Users\aykut.karagoz\source\repos\blogwebapplication\entrypoint.sh:/app/entrypoint.sh:rw': invalid mount config for type "bind": source path must be a directory
ERROR: for mssql Cannot create container for service mssql: invalid volume specification: 'C:\Users\aykut.karagoz\source\repos\blogwebapplication\entrypoint.sh:/app/entrypoint.sh:rw': invalid mount config for type "bind": source path must be a directory
Encountered errors while bringing up the project.
是否存在拼写错误,逻辑错误或路径错误?
docker-compose
version: '3.4'
services:
mssql:
image: "mcr.microsoft.com/mssql/server"
container_name: mssql
command: /bin/bash ./entrypoint.sh
ports:
- 1433:1433
environment:
- ACCEPT_EULA:"Y"
- SA_PASSWORD:"Asdf1234"
- MSSQL_AGENT_ENABLED:"true"
volumes:
# - dbdata:/var/opt/mssql/data
- ./entrypoint.sh:/app/entrypoint.sh
- ./db-init.sh:/app/db-init.sh
- ./db-init.sql:/app/db-init.sql
client:
build:
dockerfile: Blog.Web/Dockerfile
context: .
depends_on:
- mssql
dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-nanoserver-1903 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-nanoserver-1903 AS build
WORKDIR /src
COPY ["Blog.Web/Blog.Web.csproj", "Blog.Web/"]
COPY ["Blog.BLL/Blog.BLL.csproj", "Blog.BLL/"]
COPY ["Blog.DAL/Blog.DAL.csproj", "Blog.DAL/"]
COPY ["Blog.Models/Blog.Models.csproj", "Blog.Models/"]
RUN dotnet restore "Blog.Web/Blog.Web.csproj"
COPY . .
WORKDIR "/src/Blog.Web"
RUN dotnet build "Blog.Web.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "Blog.Web.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Blog.Web.dll"]
db-init.sh
sleep 30s
echo "running set up script"
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Asdf1234 -d master -i db-init.sql
db-init.sql
此文件中有sql脚本。
entrypoint.sh
/db-init.sh & /opt/mssql/bin/sqlservr