Docker容器运行命令

时间:2019-05-22 09:56:48

标签: docker docker-compose

我有一个类似

的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

和像{p1这样的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"

0 个答案:

没有答案