Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM microsoft/dotnet:1.0.0-preview2.1-nanoserver-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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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\`.
Expand Down
24 changes: 24 additions & 0 deletions docker-compose.windows.yml
Original file line number Diff line number Diff line change
@@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it help to debug? You can't connect to the port from the host machine.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dermeister0 yeah you can - depending on the configuration, it's available on either the IP address of the container or the host.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DB is available on the container IP even if the 'ports' directive is missing.
If port mapping is used, you can connect to the host from other machine, but not from localhost.
https://blogs.technet.microsoft.com/virtualization/2016/05/25/windows-nat-winnat-capabilities-and-limitations/


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