From 5bc2b832bc155d2c2d0a8f11b8c8f23d753b3d73 Mon Sep 17 00:00:00 2001 From: Michael Friis Date: Sun, 9 Oct 2016 14:12:30 -0700 Subject: [PATCH 1/2] Add details on running in Docker Windows containers --- Dockerfile.windows | 20 ++++++++++++++++++++ README.md | 7 +++++++ docker-compose.windows.yml | 24 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 Dockerfile.windows create mode 100644 docker-compose.windows.yml diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 000000000..e362d3acf --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,20 @@ +FROM microsoft/dotnet:1.0.0-preview2-windowsservercore-sdk + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] + +# REMARK: Temporary workaround for Windows DNS client weirdness +RUN set-itemproperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord + +RUN New-Item -Path \MusicStore\samples\MusicStore.Standalone -Type Directory +WORKDIR MusicStore + +ADD samples/MusicStore.Standalone/project.json samples/MusicStore.Standalone/project.json +ADD NuGet.config . +RUN dotnet restore --no-cache .\samples\MusicStore.Standalone + +ADD samples samples +RUN dotnet build .\samples\MusicStore.Standalone + +EXPOSE 5000 +ENV ASPNETCORE_URLS http://0.0.0.0:5000 +CMD dotnet run -p .\samples\MusicStore.Standalone \ No newline at end of file diff --git a/README.md b/README.md index 9099dd877..cc4931b8f 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,13 @@ This project is part of ASP.NET Core. You can find samples, documentation and ge * **[CustomHost]:** 6. Run `dnx . run` (This hosts the app in a console application - Application started at URL **http://localhost:5003/**). +## Run on Docker Windows Containers + + * [Setup up Docker Windows containers](https://msdn.microsoft.com/en-us/virtualization/windowscontainers/containers_welcome) + * `docker-compose -f .\docker-compose.windows.yml build` + * `docker-compose -f .\docker-compose.windows.yml up` + * Access MusicStore on either the Windows VM IP or (if container is running locally) on the container IP: `docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" musicstore_web_1` + ## To run the sample on Mac/Mono: * Follow the instructions at the [Home](https://github.com/aspnet/Home) repository to install Mono and DNVM on Mac OS X. * Open a command prompt and execute `cd \src\MusicStore\`. diff --git a/docker-compose.windows.yml b/docker-compose.windows.yml new file mode 100644 index 000000000..5f42aba67 --- /dev/null +++ b/docker-compose.windows.yml @@ -0,0 +1,24 @@ +version: '2' +services: + db: + image: microsoft/mssql-server-2016-express-windows + environment: + sa_password: "Password1" + ports: + - "1433:1433" # for debug. Remove this for production + + web: + build: + context: . + dockerfile: Dockerfile.windows + environment: + - "Data:DefaultConnection:ConnectionString=Server=db,1433;Database=MusicStore;User Id=sa;Password=Password1;MultipleActiveResultSets=True" + depends_on: + - "db" + ports: + - "5000:5000" + +networks: + default: + external: + name: nat \ No newline at end of file From f36417f398742e6b79e9467f8be250886a1b1cc0 Mon Sep 17 00:00:00 2001 From: Taylor Brown Date: Fri, 28 Oct 2016 15:03:08 -0700 Subject: [PATCH 2/2] Update Dockerfile.windows Changing from server core to nano - this speeds up build, run and download times. --- Dockerfile.windows | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.windows b/Dockerfile.windows index e362d3acf..1b1860fd2 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -1,4 +1,4 @@ -FROM microsoft/dotnet:1.0.0-preview2-windowsservercore-sdk +FROM microsoft/dotnet:1.0.0-preview2.1-nanoserver-sdk SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] @@ -17,4 +17,4 @@ RUN dotnet build .\samples\MusicStore.Standalone EXPOSE 5000 ENV ASPNETCORE_URLS http://0.0.0.0:5000 -CMD dotnet run -p .\samples\MusicStore.Standalone \ No newline at end of file +CMD dotnet run -p .\samples\MusicStore.Standalone