[WIP] Updates based on review of docs (#508)

* Updates based on review of docs

* Add instructions for Windows Server 2016 and ACI

* Update Windows support

* Remove CliReferenceTool references

* Update ASP.NET Core sample

* Update samples per review]

* Update ARM32 and Alpine samples to nightly

* Switch to aspnetcore-runtime image

* Switch most Dockerfiles from dotnet-nightly to dotnet

* Simplify ARM32 self-contained Dockerfile

* Add latest dockerfile

* Update FROM statement

* Update FROM statement for runtime

* Update ARM32 instructions for ASP.NET Core

* Update approach for .latest concept

* Restore only for app project

* Update text for 'preview' Dockerfiles

* Update per feedback on dotnet reference link

* Update ARM32 Dockerfile links in DH README

* Add links between ARM32 topics

* Add usage samples to ARM32 docs

* Update Dockerfile location

* Update per feedback

* Remove target manifest property
This commit is contained in:
Rich Lander 2018-05-06 17:41:05 -07:00 коммит произвёл GitHub
Родитель dc0f2db974
Коммит 928292bc0c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
24 изменённых файлов: 261 добавлений и 161 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
# Build output
[Bb]in/
[Oo]bj/
out/
[Oo]ut/
# cache for misc downloads
artifacts/

Просмотреть файл

@ -137,8 +137,8 @@ The [.NET Core Docker samples](https://github.com/dotnet/dotnet-docker/blob/mast
### ARM32 / Raspberry Pi
* [.NET Core ARM32 Docker Sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/dotnet-docker-arm32.md) - This [sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/Dockerfile.debian-arm32) builds and runs an application with Debian on ARM32 (works on Raspberry Pi).
* [ASP.NET Core ARM32 Docker Sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/README.md) - This [sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/Dockerfile.debian-arm32) builds and runs an ASP.NET Core application with Debian on ARM32 (works on Raspberry Pi).
* [.NET Core ARM32 Docker Sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/dotnet-docker-arm32.md) - This [sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/Dockerfile.basic-preview) builds and runs an application with Debian on ARM32 (works on Raspberry Pi).
* [ASP.NET Core ARM32 Docker Sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/README.md) - This [sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/Dockerfile.preview) builds and runs an ASP.NET Core application with Debian on ARM32 (works on Raspberry Pi).
## Image variants

Просмотреть файл

@ -6,9 +6,9 @@ The samples exercise various levels of functionality. The [.NET Core Docker samp
## Try a pre-built .NET Core Docker Image
You can quickly try a pre-built [sample .NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on the [.NET Core sample](dotnetapp/README.md).
You can quickly run a container with a pre-built [.NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on the [.NET Core console sample](dotnetapp/README.md).
Type the following command to run a sample with [Docker](https://www.docker.com/products/docker):
Type the following [Docker](https://www.docker.com/products/docker) command:
```console
docker run --rm microsoft/dotnet-samples
@ -40,11 +40,15 @@ docker run --rm microsoft/dotnet-samples
* [.NET Core ARM32 Docker Sample](dotnetapp/dotnet-docker-arm32.md) - This [sample](dotnetapp/Dockerfile.debian-arm32) builds and runs an application with Debian on ARM32 (works on Raspberry Pi).
* [ASP.NET Core ARM32 Docker Sample](aspnetapp/README.md) - This [sample](aspnetapp/Dockerfile.debian-arm32) builds and runs an ASP.NET Core application with Debian on ARM32 (works on Raspberry Pi).
## ARM64
* [.NET Core ARM64 Docker Status](dotnetapp/dotnet-docker-arm64.md)
## .NET Core Resources
More Samples
* [.NET Framework Docker Samples](https://github.com/microsoft/dotnet-framework-docker-samples/)
* [.NET Framework Docker Samples](https://github.com/microsoft/dotnet-framework-docker/blob/master/samples/README.md)
Docs and More Information:
@ -66,5 +70,4 @@ Docs and More Information:
* [microsoft/aspnet](https://hub.docker.com/r/microsoft/aspnet/) for ASP.NET Web Forms and MVC images.
* [microsoft/dotnet-framework](https://hub.docker.com/r/microsoft/dotnet-framework/) for .NET Framework images.
* [microsoft/dotnet-framework-build](https://hub.docker.com/r/microsoft/dotnet-framework-build/) for building .NET Framework applications with Docker.
* [microsoft/dotnet-framework-samples](https://hub.docker.com/r/microsoft/dotnet-framework-samples/) for .NET Framework and ASP.NET sample images.

Просмотреть файл

@ -9,11 +9,10 @@ RUN dotnet restore
# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /app/aspnetapp
RUN dotnet publish -o out /p:PublishWithAspNetCoreTargetManifest="false"
RUN dotnet publish -c release -o out
FROM microsoft/dotnet:2.0-runtime AS runtime
ENV ASPNETCORE_URLS http://+:80
FROM microsoft/aspnetcore:2.0 AS runtime
WORKDIR /app
COPY --from=build /app/aspnetapp/out ./
ENTRYPOINT ["dotnet", "aspnetapp.dll"]

Просмотреть файл

@ -0,0 +1,18 @@
FROM microsoft/dotnet:2.1-sdk-alpine AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore
# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /app/aspnetapp
RUN dotnet publish -c release -o out
FROM microsoft/dotnet:2.1-aspnetcore-runtime-alpine AS runtime
WORKDIR /app
COPY --from=build /app/aspnetapp/out ./
ENTRYPOINT ["dotnet", "aspnetapp.dll"]

Просмотреть файл

@ -7,13 +7,12 @@ COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore
# copy everything else and build app
COPY . .
COPY aspnetapp/. ./aspnetapp/
WORKDIR /app/aspnetapp
RUN dotnet publish -o out /p:PublishWithAspNetCoreTargetManifest="false"
RUN dotnet publish -c release -o out
FROM microsoft/dotnet:2.0-runtime-stretch-arm32v7 AS runtime
ENV ASPNETCORE_URLS http://+:80
FROM microsoft/aspnetcore:2.0-nanoserver-sac2016 AS runtime
WORKDIR /app
COPY --from=build /app/aspnetapp/out ./
ENTRYPOINT ["dotnet", "aspnetapp.dll"]

Просмотреть файл

@ -0,0 +1,18 @@
FROM microsoft/dotnet-nightly:2.1-sdk AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore
# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /app/aspnetapp
RUN dotnet publish -c release -o out
FROM microsoft/dotnet-nightly:2.1-aspnetcore-runtime AS runtime
WORKDIR /app
COPY --from=build /app/aspnetapp/out ./
ENTRYPOINT ["dotnet", "aspnetapp.dll"]

Просмотреть файл

@ -8,7 +8,7 @@ This sample requires [Docker 17.06](https://docs.docker.com/release-notes/docker
## Try a pre-built ASP.NET Core Docker Image
You can quickly try a pre-built [sample ASP.NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on this sample.
You can quickly run a container with a pre-built [sample ASP.NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on this [sample](Dockerfile).
Type the following command to run a sample with [Docker](https://www.docker.com/products/docker):
@ -16,7 +16,7 @@ Type the following command to run a sample with [Docker](https://www.docker.com/
docker run --name aspnetcore_sample --rm -it -p 8000:80 microsoft/dotnet-samples:aspnetapp
```
After the application starts, navigate to `http://localhost:8000` in your web browser. You need to navigate to the application via IP address instead of `localhost` for Windows containers, which is demonstrated in the [View the ASP.NET Core app in a running container on Windows](#view-the-aspnet-core-app-in-a-running-container-on-windows) section.
After the application starts, navigate to `http://localhost:8000` in your web browser. On earlier versions of Windows 10 and Windows Server, you need to navigate to the application via IP address instead of `localhost` for Windows containers, which is demonstrated in the [View the ASP.NET Core app in a running container on Windows](#view-the-aspnet-core-app-in-a-running-container-on-windows) section.
## Getting the sample
@ -56,11 +56,13 @@ Note: The `-p` argument maps port 8000 on your local machine to port 80 in the c
Multiple variations of this sample have been provided, as follows. Some of these example Dockerfiles are demonstrated later. Specify an alternate Dockerfile via the `-f` argument.
* [Multi-arch sample](Dockerfile)
* [Linux ARM32 (Raspberry Pi) sample](Dockerfile.debian-arm32)
* [Multi-arch sample, using a preview version of .NET Core](Dockerfile.preview)
* [Nanoserver 2016 SAC sample](Dockerfile.nanoserver-sac2016)
* [Alpine sample](Dockerfile.alpine-x64)
### View the ASP.NET Core app in a running container on Windows
After the application starts, navigate to the container IP (as opposed to http://localhost) in your web browser with the the following instructions:
After the ASP.NET Core application starts, navigate to the container IP (as opposed to http://localhost) in your web browser with the the following instructions:
1. Open up another command prompt.
1. Run `docker exec aspnetcore_sample ipconfig`.
@ -94,7 +96,7 @@ C:\git\dotnet-docker\samples\aspnetapp>docker inspect -f "{{ .NetworkSettings.Ne
## Deploying to Production vs Development
The approach for running containers differs between development and production.
The approach for running containers differs between development and production.
In production, you will typically start your container with `docker run -d`. This argument starts the container as a service, without any console interaction. You then interact with it through other Docker commands or APIs exposed by the containerized application.
@ -102,6 +104,26 @@ In development, you will typically start containers with `docker run --rm -it`.
We recommend that you do not use `--rm` in production. It cleans up container resources, preventing you from collecting logs that may have been captured in a container that has either stopped or crashed.
## Build and run the sample for Alpine X64 with Docker
You can build and run the sample for Alpine using the following instructions. Make sure Docker is set to Linux containers if you are on Windows.
```console
cd samples
cd aspnetapp
docker build --pull -t aspnetapp -f Dockerfile.alpine-x64 .
docker run --name aspnetcore_sample --rm -it -p 8000:80 aspnetapp
```
After the application starts, navigate to `http://localhost:8000` in your web browser.
## Build and run the sample for Ubuntu 18.04 with Docker
You can also build for [Ubuntu 18.04](https://hub.docker.com/_/ubuntu/), with a `bionic` tag. The `bionic` tags are documented at [microsoft/dotnet](https://hub.docker.com/r/microsoft/dotnet/). You would switch to the following tags:
* SDK: 2.1-sdk-bionic
* Runtime:-2.1-aspnetcore-runtime-bionic
## Build and run the sample for Linux ARM32 with Docker
You can build and run the sample for ARM32 and Raspberry Pi with [Build ASP.NET Core Applications for Raspberry Pi with Docker](aspnetcore-docker-arm32.md) instructions.
@ -135,14 +157,14 @@ cd out
dotnet aspnetapp.dll
```
Note: The `-c release` argument builds the application in release mode (the default is debug mode). See the [dotnet run reference](https://docs.microsoft.com/dotnet/core/tools/dotnet-run) for more information on commandline parameters.
Note: The `-c release` argument builds the application in release mode (the default is debug mode). See the [dotnet publish reference](https://docs.microsoft.com/dotnet/core/tools/dotnet-publish) for more information on commandline parameters.
## .NET Core Resources
More Samples
* [.NET Core Docker Samples](../README.md)
* [.NET Framework Docker Samples](https://github.com/microsoft/dotnet-framework-docker-samples/)
* [.NET Framework Docker Samples](https://github.com/microsoft/dotnet-framework-docker/blob/master/samples/README.md)
Docs and More Information:
@ -164,5 +186,4 @@ Docs and More Information:
* [microsoft/aspnet](https://hub.docker.com/r/microsoft/aspnet/) for ASP.NET Web Forms and MVC images.
* [microsoft/dotnet-framework](https://hub.docker.com/r/microsoft/dotnet-framework/) for .NET Framework images.
* [microsoft/dotnet-framework-build](https://hub.docker.com/r/microsoft/dotnet-framework-build/) for building .NET Framework applications with Docker.
* [microsoft/dotnet-framework-samples](https://hub.docker.com/r/microsoft/dotnet-framework-samples/) for .NET Framework and ASP.NET sample images.

Просмотреть файл

@ -36,7 +36,7 @@ The instructions assume that you are in the root of the repository. You can use
docker run --rm -it -p 8000:80 -v c:\git\dotnet-docker\samples\aspnetapp:/app/ -w /app/aspnetapp microsoft/dotnet:2.1-sdk dotnet watch run
```
Navigate to the site at `http://localhost:8000` in your browser. You can use CTRL-C to terminate `dotnet watch`. It can take up to 20s to terminate.
Navigate to the site at `http://localhost:8000` in your browser. You can use CTRL-C to terminate `dotnet watch`.
**macOS or Linux** using **Linux containers**
@ -44,17 +44,17 @@ Navigate to the site at `http://localhost:8000` in your browser. You can use CTR
docker run --rm -it -p 8000:80 -v ~/git/dotnet-docker/samples/aspnetapp:/app/ -w /app/aspnetapp microsoft/dotnet:2.1-sdk dotnet watch run
```
Navigate to the site at `http://localhost:8000` in your browser. You can use CTRL-C to terminate `dotnet watch`. It can take up to 20s to terminate.
Navigate to the site at `http://localhost:8000` in your browser. You can use CTRL-C to terminate `dotnet watch`.
**Windows** using **Windows containers**
`dotnet watch run` is not working correctly in containers at this time. The instructions are still documented while we work on enabling this scenario.
```console
docker run --rm -it -p 8000:80 -v c:\git\dotnet-docker\samples\aspnetapp:c:\app\ -w \app\aspnetapp --name aspnetappsample microsoft/dotnet:2.1-sdk dotnet watch run
```
In another command window, type `docker exec aspnetappsample ipconfig`. Navigate to the IP address you see in your browser.
On the latest Windows versions, you can navigate to the site at `http://localhost:8000` in your browser. You can use CTRL-C to terminate `dotnet watch`.
One earlier Windows 10 and Windows Server verisons, you must navigate to the site by IP address. In another command window, type `docker exec aspnetappsample ipconfig`. Navigate to the IP address you see in your browser.
### Updating the site while the container is running

Просмотреть файл

@ -8,9 +8,14 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1E1C7ABA-885A-4273-811E-B66AD28F9A87}"
ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore
aspnet-docker-dev-in-container.md = aspnet-docker-dev-in-container.md
aspnetcore-docker-arm32.md = aspnetcore-docker-arm32.md
deploy-container-to-aci.md = deploy-container-to-aci.md
Directory.Build.props = Directory.Build.props
Dockerfile = Dockerfile
Dockerfile.debian-arm32 = Dockerfile.debian-arm32
Dockerfile.alpine-x64 = Dockerfile.alpine-x64
Dockerfile.nanoserver-sac2016 = Dockerfile.nanoserver-sac2016
Dockerfile.preview = Dockerfile.preview
README.md = README.md
EndProjectSection
EndProject

Просмотреть файл

@ -4,25 +4,8 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
<ItemGroup>
<None Remove=".dockerignore" />
<None Remove="deploy-container-to-aci.md" />
<None Remove="Dockerfile" />
<None Remove="Dockerfile.debian-arm32" />
<None Remove="README.md" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.7" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,51 +1,39 @@
# Build and run the sample for Linux ARM32 with Docker
# Use ASP.NET Core on Linux ARM32 with Docker
You can build and run .NET Core apps with [Docker for Raspberry Pi and ARM32 devices](https://docs.docker.com/install/linux/docker-ce/debian), generally. These instructions are based on the [ASP.NET Core Docker Sample](README.md).
You can use ASP.NET Core and Docker together on [ARM32](https://en.wikipedia.org/wiki/ARM_architecture) devices, with [Docker for Raspberry Pi and ARM32 devices](https://docs.docker.com/install/linux/docker-ce/debian).
> Note: that Docker refers to ARM32 as `armhf` in documentation and other places.
## Building the Sample with Docker
See [Use .NET Core on Linux ARM32 with Docker](../dotnetapp/aspnetcore-docker-arm32.md) for .NET Core console apps.
Build the [sample](Dockerfile.debian-arm32) on a 64-bit operating system. This requirement is due to the .NET Core SDK not being currently supported on ARM32. The instructions assume that you are in the root of the repository.
See [.NET Core and Docker for ARM64](dotnet-docker-arm64.md) if you are interested in [ARM64](https://en.wikipedia.org/wiki/ARM64) usage.
## Try a pre-built ASP.NET Core Docker Image
You can quickly run a container with a pre-built [sample ASP.NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on this [sample](Dockerfile.preview).
Type the following command to run a sample with [Docker](https://www.docker.com/products/docker):
```console
docker run --rm -it -p 8000:80 microsoft/dotnet-samples:aspnetapp
```
After the application starts, navigate to `http://localhost:8000` in your web browser and/or to the IP address (example: http://192.168.1.18:8000) of your ARM32 device on your network.
## Building .NET Core Samples with Docker
You can build almost the same [.NET Core console samples](README.md) and [ASP.NET Core sample](../aspnetapp/README.md) on ARM devices as you can on other architectures. At present, the primary difference is that most .NET Core Docker file samples use the .NET Core 2.0 SDK multi-arch tags, and those don't offer `linux/arm` manifests. Starting with .NET Core 2.1, both .NET Core Runtime and SDK multi-arch tags support Linux ARM32 and are usable on ARM32 devices. [Dockerfile.preview](Dockerfile.preview) has been added to work around this issue. It uses .NET Core 2.1 instead of 2.0.
For example, the following instructions will work on an ARM32 device. The instructions assume that you are in the root of this repository.
```console
cd samples
cd aspnetapp
docker build --pull -t aspnetapp:debian-arm32 -f Dockerfile.debian-arm32 .
docker build --pull -t aspnetapp -f Dockerfile.preview .
docker run --rm -it -p 8000:80 aspnetapp
```
## Pushing the image to a Container Registry
Push the image to a container registry after building the image so that you can pull it from an ARM32 device. Instructions are provided for pushing to both Azure Container Registry and DockerHub (you only need to choose one):
* [Push Docker Images to Azure Container Registry](../dotnetapp/push-image-to-acr.md)
* [Push Docker Images to DockerHub](../dotnetapp/push-image-to-dockerhub.md)
## Pull the Image from Another Device
Next, pull the image from the registry you pushed your image to, on an ARM32 device (like a Pi).
> Note: The instructions use example values that need to be changed to for your environment, specifically the password location, and the user account. More simply, make sure to change "rich" and "richlander" to something else.
### Using Azure Container Registry (ACR)
Now pull and run the image from Azure Container Registry if you used that registry:
```console
docker pull richlander.azurecr.io/aspnetapp:debian-arm32
docker run --rm -p 8000:80 richlander.azurecr.io/aspnetapp:debian-arm32
```
First `docker login` to Azure Container Registry. See [Push Docker Images to Azure Container Registry](../dotnetapp/push-image-to-acr.md) for instructions on how to do that.
### Using DockerHub
Now pull and run the image from DockerHub if you used that registry:
```console
docker pull richlander/aspnetapp:debian-arm32
docker run --rm -p 8000:80 richlander/aspnetapp:debian-arm32
```
Another option is to build ARM32 Docker images on an X64 machine. You can do by using the same pattern used in the [Dockerfile.debian-arm32-selfcontained](../dotnetapp/Dockerfile.debian-arm32-selfcontained) dockerfile. It uses a multi-arch tag for building with the SDK and then an ARM32-specific tag for creating a runtime image. The pattern of building for other architectures only works because the Dockerfile doesn't run code in the runtime image.
### Viewing the Site
@ -54,6 +42,15 @@ After the application starts, visit the site one of two ways:
* From the web browser on the ARM32 device at `http://localhost:8000`
* From the web browser on another device on the same network on the ARM32 device IP on port 8000, similar to: `http://192.168.1.18:8000`
You must set the `ASPNETCORE_URLS` environment variable manually ([example usage](https://github.com/dotnet/dotnet-docker/blob/master/2.1/runtime-deps/stretch-slim/arm32v7/Dockerfile#L19)) if you build the sample locally (without Docker) and want to navigate to the site from another machine.
## Pushing the image to a Container Registry
Push the image to a container registry after building the image so that you can pull it from another ARM32 device. You can also build an ARM32 image on an X64 machine, push to a registry and then pull from an ARM32 device. Instructions are provided for pushing to both Azure Container Registry and DockerHub (you only need to choose one):
* [Push Docker Images to Azure Container Registry](push-image-to-acr.md)
* [Push Docker Images to DockerHub](push-image-to-dockerhub.md)
## More Samples
* [.NET Core Docker Samples](../README.md)

Просмотреть файл

@ -12,6 +12,16 @@ cd aspnetapp
docker build --pull -t aspnetapp -f Dockerfile .
```
For Windows containers, you will need to build with a [Dockerfile](Dockerfile.nanoserver-sac2016) that uses a Windows Server 2016 image. Use the following instructions for Windows containers:
```console
cd samples
cd aspnetapp
docker build --pull -t aspnetapp -f Dockerfile.nanoserver-sac2016 .
```
Windows server, version 1709 and later versions are not yet supported in ACI.
## Create ACR Registry
Create an ACR registry per the instructions at [Push Docker Images to Azure Container Registry](../dotnetapp/push-image-to-acr.md). The following is a summarized version of those instructions.
@ -49,18 +59,26 @@ docker push richlander.azurecr.io/aspnetapp
## Deploy Image to Azure Container Instance (ACI)
```console
az container create --name aspnetapp --image richlander.azurecr.io/aspnetapp --resource-group richlander-containers --ip-address public
```
Specify `--os-type Windows` for Windows images. Windows Server, version 1709 images are not yet supported.
During deployment, you'll need to enter your password. Type or copy/paste it in. Get your password beforehand from the following command:
```console
az acr credential show -n richlander --query passwords[0].value --output tsv
```
You can deploy Linux images with the following command:
```console
az container create --name aspnetapp --image richlander.azurecr.io/aspnetapp --resource-group richlander-containers --ip-address public
```
You can deploy Windows images with the following command, which includes `--os-type Windows`:
```console
az container create --name aspnetapp --image richlander.azurecr.io/aspnetapp --resource-group richlander-containers --ip-address public --os-type Windows
```
> Note: Azure Container Instances only supports Windows Server 2016 Nano Server and Server Core images, not Windows Server, version 1709 or later.
## Running the Image
The last step -- `az container show` -- will need to be repeated until `provisioningState` moves to `Succeeded`.

Просмотреть файл

@ -2,14 +2,15 @@ FROM microsoft/dotnet:2.0-sdk AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.sln .
COPY dotnetapp/*.csproj ./dotnetapp/
COPY utils/*.csproj ./utils/
COPY tests/*.csproj ./tests/
WORKDIR /app/dotnetapp
RUN dotnet restore
# copy and build everything else
COPY . .
WORKDIR /app/
COPY dotnetapp/. ./dotnetapp/
COPY utils/. ./utils/
WORKDIR /app/dotnetapp
RUN dotnet publish -c Release -o out

Просмотреть файл

@ -0,0 +1,21 @@
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY dotnetapp/*.csproj ./dotnetapp/
COPY utils/*.csproj ./utils/
WORKDIR /app/dotnetapp
RUN dotnet restore
# copy and build everything else
WORKDIR /app
COPY dotnetapp/. ./dotnetapp/
COPY utils/. ./utils/
WORKDIR /app/dotnetapp
RUN dotnet publish -c Release -o out
FROM microsoft/dotnet:2.1-runtime AS runtime
WORKDIR /app
COPY --from=build /app/dotnetapp/out ./
ENTRYPOINT ["dotnet", "dotnetapp.dll"]

Просмотреть файл

@ -1,36 +1,27 @@
FROM microsoft/dotnet:2.0-sdk AS build
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.sln .
COPY dotnetapp/*.csproj ./dotnetapp/
COPY utils/*.csproj ./utils/
COPY tests/*.csproj ./tests/
WORKDIR /app/dotnetapp
RUN dotnet restore
# copy everything else and build app
COPY . .
WORKDIR /app/
COPY dotnetapp/. ./dotnetapp/
COPY utils/. ./utils/
WORKDIR /app/dotnetapp
RUN dotnet build
FROM build AS testrunner
WORKDIR /app/tests
ENTRYPOINT ["dotnet", "test", "--logger:trx"]
FROM build AS test
WORKDIR /app/tests
RUN dotnet test
FROM build AS publish
WORKDIR /app/dotnetapp
RUN dotnet add package ILLink.Tasks -v 0.1.4-preview-981901 -s https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
RUN dotnet publish -c Release -r linux-arm -o out /p:ShowLinkerSizeComparison=true
FROM microsoft/dotnet:2.0-runtime-deps-stretch-arm32v7 AS runtime
FROM microsoft/dotnet:2.1-runtime-deps-stretch-arm32v7 AS runtime
WORKDIR /app
COPY --from=publish /app/dotnetapp/out ./
ENTRYPOINT ["./dotnetapp"]

Просмотреть файл

@ -1,4 +1,4 @@
FROM microsoft/dotnet:2.0-sdk AS build
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /app
# copy csproj and restore as distinct layers
@ -29,7 +29,7 @@ WORKDIR /app/dotnetapp
RUN dotnet publish -c Release -o out
FROM microsoft/dotnet:2.0-runtime-stretch-arm32v7 AS runtime
FROM microsoft/dotnet:2.1-runtime AS runtime
WORKDIR /app
COPY --from=publish /app/dotnetapp/out ./
ENTRYPOINT ["dotnet", "dotnetapp.dll"]

Просмотреть файл

@ -8,12 +8,12 @@ This sample requires [Docker 17.06](https://docs.docker.com/release-notes/docker
## Try a pre-built .NET Core Docker Image
You can quickly try a pre-built [sample .NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on this sample.
You can quickly run a container with a pre-built [.NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on this [sample](Dockerfile).
Type the following command to run a sample with [Docker](https://www.docker.com/products/docker):
Type the following [Docker](https://www.docker.com/products/docker) command:
```console
docker run --rm -it microsoft/dotnet-samples
docker run --rm microsoft/dotnet-samples
```
## Getting the sample
@ -49,12 +49,13 @@ You can mount a volume while running the image in order to save the test results
Multiple variations of this sample have been provided, as follows. Some of these example Dockerfiles are demonstrated later. Specify an alternate Dockerfile via the `-f` argument.
* [Multi-arch sample with build and unit testing](Dockerfile)
* [Multi-arch sample with build and unit testing, using a preview version of .NET Core](Dockerfile.preview)
* [Multi-arch basic sample](Dockerfile.basic)
* [Multi-arch basic sample, using a preview version of .NET Core](Dockerfile.basic-preview)
* [Alpine x64 sample with build and unit testing](Dockerfile.alpine-x64)
* [Alpine x64 sample, with Globalization enabled](Dockerfile.alpine-x64-globalization)
* [Nano Server self-contained x64 sample with build and unit testing](Dockerfile.nanoserver-x64-selfcontained)
* [Debian self-contained x64 sample with build and unit testing](Dockerfile.debian-x64-selfcontained)
* [Debian ARM32 sample with build and unit testing](Dockerfile.debian-arm32)
* [Debian self-contained ARM32 sample with build and unit testing](Dockerfile.debian-arm32-selfcontained)
## Build and run the sample for Alpine with Docker
@ -72,15 +73,26 @@ docker run --rm -it dotnetapp:alpine Hello .NET Core from Alpine
> Related: [.NET Core Alpine Docker Image announcement](https://github.com/dotnet/dotnet-docker-nightly/issues/500)
## Build and run the sample for Ubuntu 18.04 with Docker
You can also build for [Ubuntu 18.04](https://hub.docker.com/_/ubuntu/), with a `bionic` tag. The `bionic` tags are documented at [microsoft/dotnet](https://hub.docker.com/r/microsoft/dotnet/). You would switch to the following tags:
* SDK: 2.1-sdk-bionic
* Runtime:-2.1-runtime-bionic
## Build and run the sample for Linux ARM32 with Docker
You can build and run the sample for ARM32 and Raspberry Pi with [Build .NET Core Applications for Raspberry Pi with Docker](dotnet-docker-arm32.md) instructions.
## Build and run the sample for Linux ARM64 with Docker
* [.NET Core ARM64 Docker Status](dotnet-docker-arm64.md)
## Build .NET Core Self-Contained Applications with Docker
You can build [Build .NET Core Self-Contained Applications with Docker](dotnet-docker-selfcontained.md).
## Develop ASP.NET Core Applications in a container
## Develop .NET Core Applications in a container
You can develop applications without a .NET Core installation on your machine with the [Develop .NET Core applications in a container](dotnet-docker-dev-in-container.md) instructions. These instructions are also useful if your development and production environments do not match.
@ -101,27 +113,27 @@ cd dotnetapp
dotnet run Hello .NET Core
```
You can produce an application that is ready to deploy to production locally using the following command.
You can produce an application that is ready to deploy to production using the following command.
```console
dotnet publish -c release -o out
```
You can run the application using the following command.
You can run the published application using the following command:
```console
cd out
dotnet dotnetapp.dll
```
Note: The `-c release` argument builds the application in release mode (the default is debug mode). See the [dotnet run reference](https://docs.microsoft.com/dotnet/core/tools/dotnet-run) for more information on commandline parameters.
Note: The `-c release` argument builds the application in release mode (the default is debug mode). See the [dotnet publish reference](https://docs.microsoft.com/dotnet/core/tools/dotnet-publish) for more information on commandline parameters.
## .NET Core Resources
## .NET Resources
More Samples
* [.NET Core Docker Samples](../README.md)
* [.NET Framework Docker Samples](https://github.com/microsoft/dotnet-framework-docker-samples/)
* [.NET Framework Docker Samples](https://github.com/microsoft/dotnet-framework-docker/blob/master/samples/README.md)
Docs and More Information:
@ -143,5 +155,4 @@ Docs and More Information:
* [microsoft/aspnet](https://hub.docker.com/r/microsoft/aspnet/) for ASP.NET Web Forms and MVC images.
* [microsoft/dotnet-framework](https://hub.docker.com/r/microsoft/dotnet-framework/) for .NET Framework images.
* [microsoft/dotnet-framework-build](https://hub.docker.com/r/microsoft/dotnet-framework-build/) for building .NET Framework applications with Docker.
* [microsoft/dotnet-framework-samples](https://hub.docker.com/r/microsoft/dotnet-framework-samples/) for .NET Framework and ASP.NET sample images.

Просмотреть файл

@ -1,59 +1,60 @@
# Build .NET Core Applications for ARM32 and Raspberry Pi with Docker
# Use .NET Core and Docker on ARM32 and Raspberry Pi
You can build and run .NET Core apps with [Docker for Raspberry Pi and ARM32 devices](https://docs.docker.com/install/linux/docker-ce/debian), generally. These instructions are based on the [.NET Core Docker Sample](README.md).
You can use .NET Core and Docker together on [ARM32](https://en.wikipedia.org/wiki/ARM_architecture) devices, with [Docker for Raspberry Pi and ARM32 devices](https://docs.docker.com/install/linux/docker-ce/debian).
> Note: that Docker refers to ARM32 as `armhf` in documentation and other places.
## Building the Sample with Docker
See [Use ASP.NET Core on Linux ARM32 with Docker](../aspnetapp/aspnetcore-docker-arm32.md) for ASP.NET Core apps.
This [sample](Dockerfile.debian-arm32) must be built on a 64-bit operating system, as the .NET Core SDK is not currently supported on ARM32. The instructions assume that you are in the root of the repository.
See [.NET Core and Docker for ARM64](dotnet-docker-arm64.md) if you are interested in [ARM64](https://en.wikipedia.org/wiki/ARM64) usage.
> Note: .NET Core can be be used with devices that use [ARMv7](https://en.wikipedia.org/wiki/ARMv7) and [ARMv8](https://en.wikipedia.org/wiki/ARMv8) chips, for example [Raspberry Pi2](https://www.raspberrypi.org/products/raspberry-pi-2-model-b/) and [Raspberry Pi3](https://www.raspberrypi.org/products/raspberry-pi-3-model-b-plus/), respectively. .NET Core does not support [ARMv6 / ARM11](https://en.wikipedia.org/wiki/ARM11) devices, for example [Raspberry Pi Zero](https://www.raspberrypi.org/products/raspberry-pi-zero/).
## Try a pre-built .NET Core Docker Image
You can quickly run a container with a pre-built [.NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on this [sample](Dockerfile.basic-preview).
Type the following [Docker](https://www.docker.com/products/docker) command:
```console
docker run --rm microsoft/dotnet-samples
```
## Building .NET Core Samples with Docker
You can build almost the same [.NET Core console samples](README.md) and [ASP.NET Core sample](../aspnetapp/README.md) on ARM devices as you can on other architectures. At present, the primary difference is that most .NET Core Docker file samples use the .NET Core 2.0 SDK multi-arch tags, and those don't offer `linux/arm` manifests. Starting with .NET Core 2.1, both .NET Core Runtime and SDK multi-arch tags support Linux ARM32 and are usable on ARM32 devices. [Dockerfile.preview](Dockerfile.preview) and [Dockerfile.preview](Dockerfile.basic-preview) have been added to work around this issue. They use .NET Core 2.1 instead of 2.0.
For example, the following instructions will work on an ARM32 device. The instructions assume that you are in the root of this repository.
```console
cd samples
cd dotnetapp
docker build --pull -t dotnetapp:debian-arm32 -f Dockerfile.debian-arm32 .
docker build --pull -t dotnetapp -f Dockerfile.preview .
docker run --rm dotnetapp
```
See [Build .NET Core Self-Contained Applications with Docker](dotnet-docker-selfcontained.md) to build a self-contained .NET Core ARM32 application.
Another option is to build ARM32 Docker images on an X64 machine. You can do by using the same pattern used in the [Dockerfile.debian-arm32-selfcontained](Dockerfile.debian-arm32-selfcontained) dockerfile (demonstrated in a following section). It uses a multi-arch tag for building with the SDK and then an ARM32-specific tag for creating a runtime image. The pattern of building for other architectures only works because the Dockerfile doesn't run code in the runtime image.
Multiple variations of this sample have been provided, as follows. Some of these example Dockerfiles are demonstrated later. Specify an alternate Dockerfile via the `-f` argument.
## Building Self-contained Applications for ARM32
* [Debian ARM32 sample with build and unit testing](Dockerfile.debian-arm32)
* [Debian self-contained ARM32 sample with build and unit testing](Dockerfile.debian-arm32-selfcontained)
You can [Build .NET Core Self-Contained Applications with Docker](dotnet-docker-selfcontained.md) for an ARM32 deployment using this [Dockerfile](Dockerfile.debian-arm32-selfcontained).
The instructions assume that you are in the root of this repository.
```console
cd samples
cd dotnetapp
docker build --pull -t dotnetapp -f Dockerfile.debian-arm32-selfcontained .
docker run --rm dotnetapp
```
## Pushing the image to a Container Registry
Push the image to a container registry after building the image so that you can pull it from an ARM32 device. Instructions are provided for pushing to both Azure Container Registry and DockerHub (you only need to choose one):
Push the image to a container registry after building the image so that you can pull it from another ARM32 device. You can also build an ARM32 image on an X64 machine, push to a registry and then pull from an ARM32 device. Instructions are provided for pushing to both Azure Container Registry and DockerHub (you only need to choose one):
* [Push Docker Images to Azure Container Registry](push-image-to-acr.md)
* [Push Docker Images to DockerHub](push-image-to-dockerhub.md)
## Pull the Image from Another Device
Next, pull the image on an ARM32 device (like a Pi) from the recently pushed registry.
> Note: Change the password location and the user account ("rich" and "richlander") example values in your environment.
### Using Azure Container Registry (ACR)
Now pull and run the image from Azure Container Registry if you used that registry:
```console
docker pull richlander.azurecr.io/dotnetapp:debian-arm32
docker run --rm richlander.azurecr.io/dotnetapp:debian-arm32
```
First `docker login` to Azure Container Registry. For more information, see [Push Docker Images to Azure Container Registry](push-image-to-acr.md).
### Using DockerHub
Now pull and run the image from DockerHub if you used that registry:
```console
docker pull richlander/dotnetapp:debian-arm32
docker run --rm richlander/dotnetapp:debian-arm32
```
## More Samples
* [.NET Core Docker Samples](../README.md)

Просмотреть файл

@ -0,0 +1,7 @@
# .NET Core and Docker for ARM64
We are in the process of enabling .NET Core on ARM64, including with Docker. See [dotnet/dotnet-docker # 509](https://github.com/dotnet/dotnet-docker/pull/509) to follow the progress.
Please see [.NET Core and Docker for ARM32](dotnet-docker-arm64.md) if you are interested in [ARM32](https://en.wikipedia.org/wiki/ARM_architecture) usage.
You can run the ARM32 build of .NET Core on an ARM64 machine. You need to install the `armhf` versions of .NET Core's dependent packages for that to work. The dependent packages are documented in the `runtime-deps` [Dockerfile](https://github.com/dotnet/dotnet-docker/blob/master/2.1/runtime-deps/stretch-slim/arm32v7/Dockerfile) for each distro.

Просмотреть файл

@ -76,18 +76,21 @@ Use the following commands, given your environment:
**Windows** using **Linux containers**
```console
mkdir TestResults
docker run --rm -v C:\git\dotnet-docker\samples\dotnetapp\TestResults:/app/tests/TestResults dotnetapp:test
```
**Linux or macOS** using **Linux containers**
```console
mkdir TestResults
docker run --rm -v "$(pwd)"/TestResults:/app/tests/TestResults dotnetapp:test
```
**Windows** using **Windows containers**
```console
mkdir TestResults
docker run --rm -v C:\git\dotnet-docker\samples\dotnetapp\TestResults:C:\app\tests\TestResults dotnetapp:test
```

Просмотреть файл

@ -11,15 +11,19 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{90F9D14D-E209-4E8D-962B-B1FD13751A74}"
ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore
Directory.Build.props = Directory.Build.props
Dockerfile = Dockerfile
Dockerfile.alpine-x64 = Dockerfile.alpine-x64
Dockerfile.alpine-x64-globalization = Dockerfile.alpine-x64-globalization
Dockerfile.basic = Dockerfile.basic
Dockerfile.debian-arm32 = Dockerfile.debian-arm32
Dockerfile.basic-preview = Dockerfile.basic-preview
Dockerfile.debian-arm32-selfcontained = Dockerfile.debian-arm32-selfcontained
Dockerfile.debian-x64-selfcontained = Dockerfile.debian-x64-selfcontained
Dockerfile.nanoserver-x64-selfcontained = Dockerfile.nanoserver-x64-selfcontained
Dockerfile.preview = Dockerfile.preview
dotnet-docker-arm32.md = dotnet-docker-arm32.md
dotnet-docker-arm64.md = dotnet-docker-arm64.md
dotnet-docker-dev-in-container.md = dotnet-docker-dev-in-container.md
dotnet-docker-selfcontained.md = dotnet-docker-selfcontained.md
dotnet-docker-unit-testing.md = dotnet-docker-unit-testing.md
push-image-to-acr.md = push-image-to-acr.md

Просмотреть файл

@ -1,10 +1,10 @@
# Push Docker Images to Azure Container Registry
This sample demonstrates how to push .NET Core images to [Azure Container Registry (ACR)](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal). The instructions are based on the [.NET Core Docker Sample](README.md).
This sample demonstrates how to push .NET Core images to [Azure Container Registry (ACR)](https://docs.microsoft.com/azure/container-registry/container-registry-get-started-portal). The instructions are based on the [.NET Core Docker Sample](README.md).
These instructions use the [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli) and the [Docker client](https://www.docker.com/products/docker).
Similar instructions are also available to [push to Azure DockerHub](push-image-to-dockerhub.md).
Similar instructions are also available to [push to DockerHub](push-image-to-dockerhub.md).
## Build the Image
@ -96,7 +96,7 @@ First, `docker login` to ACR before you can pull the image from another device,
Update the path locations, registry, and user names to the ones you are using.
Now pull and run the image:
Now pull and run the image (the first command isn't strictly necessary):
```console
docker pull richlander.azurecr.io/dotnetapp

Просмотреть файл

@ -6,7 +6,7 @@ Similar instructions are also available to [push to Azure Container Registry](pu
## Build the Image
The following instructions are a subset of the [.NET Core Docker Sample](dotnetapp/README.md) instructions, which assume that you are starting from the root of the [dotnet-docker repo](https://github.com/dotnet/dotnet-docker).
The following instructions are a subset of the [.NET Core Docker Sample](README.md) instructions, which assume that you are starting from the root of the [dotnet-docker repo](https://github.com/dotnet/dotnet-docker).
```console
cd samples