Search This Blog

Wednesday, August 14, 2019

Customize a Docker image to run your own web app- source microsoft

git clone https://github.com/MicrosoftDocs/mslearn-hotel-reservation-system.git

cd mslearn-hotel-reservation-system/src

copy NUL Dockerfile
notepad Dockerfile

FROM microsoft/dotnet:2.1-sdk
WORKDIR /src
COPY ["HotelReservationSystem/HotelReservationSystem.csproj", "HotelReservationSystem/"]
COPY ["HotelReservationSystemTypes/HotelReservationSystemTypes.csproj", "HotelReservationSystemTypes/"]
RUN dotnet restore "HotelReservationSystem/HotelReservationSystem.csproj"

COPY . .
WORKDIR "/src/HotelReservationSystem"
RUN dotnet build "HotelReservationSystem.csproj" -c Release -o /app

RUN dotnet publish "HotelReservationSystem.csproj" -c Release -o /app

EXPOSE 80
WORKDIR /app
ENTRYPOINT ["dotnet", "HotelReservationSystem.dll"]

docker build -t reservationsystem .

docker image list

docker run -p 8080:80 -d --name reservations reservationsystem

docker ps -a

docker container stop reservations

docker rm reservations

1 comment:

  1. hola estoy intentando segir la logica pero me aparece un error por fa una gia

    sudo docker build -t reservationsystem .
    Sending build context to Docker daemon 29.7kB
    Step 1/12 : FROM mcr.microsoft.com/dotnet/core/sdk:2.2
    ---> 2357b6790b9d
    Step 2/12 : WORKDIR /src
    ---> Using cache
    ---> feafe0d8b75f
    Step 3/12 : COPY ["HotelReservationSystem/HotelReservationSystem.csproj", "HotelReservetionSystem/"]
    ---> Using cache
    ---> 9a63acb2cbd3
    Step 4/12 : COPY ["HotelReservationSystemTypes/HotelReservationSystemTypes.csproj", "HotelReservationSystemTypes/"]
    ---> Using cache
    ---> f929fbe2433b
    Step 5/12 : RUN dotnet restore "HotelReservationSystem/HotelReservationSystem.csproj"
    ---> Running in 6fd57ea0e93f
    MSBUILD : error MSB1009: Project file does not exist.
    Switch: HotelReservationSystem/HotelReservationSystem.csproj
    The command '/bin/sh -c dotnet restore "HotelReservationSystem/HotelReservationSystem.csproj"' returned a non-zero code: 1

    ReplyDelete