mirror of https://github.com/docker/docs.git
commit
554e9c2e25
|
@ -6,15 +6,15 @@ title: "Quickstart: Compose and ASP.NET Core with SQL Server"
|
|||
|
||||
This quick-start guide demonstrates how to use Docker Engine on Linux and Docker
|
||||
Compose to set up and run the sample ASP.NET Core application using the
|
||||
[ASP.NET Core Build image](https://hub.docker.com/r/microsoft/aspnetcore-build/)
|
||||
[.NET Core SDK image](hub.docker.com/_/microsoft-dotnet-core-sdk)
|
||||
with the
|
||||
[SQL Server on Linux image](https://hub.docker.com/r/microsoft/mssql-server-linux/).
|
||||
[SQL Server on Linux image](https://hub.docker.com/_/microsoft-mssql-server).
|
||||
You just need to have [Docker Engine](/install/index.md)
|
||||
and [Docker Compose](/compose/install/) installed on your
|
||||
platform of choice: Linux, Mac or Windows.
|
||||
|
||||
For this sample, we create a sample .NET Core Web Application using the
|
||||
`aspnetcore-build` Docker image. After that, we create a `Dockerfile`,
|
||||
`microsoft/dotnet:2.1-sdk` Docker image. After that, we create a `Dockerfile`,
|
||||
configure this app to use our SQL Server database, and then create a
|
||||
`docker-compose.yml` that defines the behavior of all of these components.
|
||||
|
||||
|
@ -29,12 +29,12 @@ configure this app to use our SQL Server database, and then create a
|
|||
[Docker Desktop for Mac](/docker-for-mac/#/file-sharing), you
|
||||
need to set up file sharing for the volume that you need to map.
|
||||
|
||||
1. Within your directory, use the `aspnetcore-build` Docker image to generate a
|
||||
1. Within your directory, use the `dotnet:2.1-sdk` Docker image to generate a
|
||||
sample web application within the container under the `/app` directory and
|
||||
into your host machine in the working directory:
|
||||
|
||||
```bash
|
||||
$ docker run -v ${PWD}:/app --workdir /app microsoft/aspnetcore-build:lts dotnet new mvc --auth Individual
|
||||
$ docker run -v ${PWD}:/app --workdir /app microsoft/dotnet:2.1-sdk dotnet new mvc --auth Individual
|
||||
```
|
||||
|
||||
> **Note**: If running in Docker Desktop for Windows, make sure to use Powershell
|
||||
|
@ -43,7 +43,7 @@ configure this app to use our SQL Server database, and then create a
|
|||
1. Create a `Dockerfile` within your app directory and add the following content:
|
||||
|
||||
```conf
|
||||
FROM microsoft/aspnetcore-build:lts
|
||||
FROM microsoft/dotnet:2.1-sdk
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
RUN ["dotnet", "restore"]
|
||||
|
@ -54,7 +54,7 @@ configure this app to use our SQL Server database, and then create a
|
|||
```
|
||||
|
||||
This file defines how to build the web app image. It uses the
|
||||
[microsoft/aspnetcore-build](https://hub.docker.com/r/microsoft/aspnetcore-build/),
|
||||
[.NET Core SDK image](https://hub.docker.com/_/microsoft-dotnet-core-sdk),
|
||||
maps the volume with the generated code, restores the dependencies, builds the
|
||||
project and exposes port 80. After that, it calls an `entrypoint` script
|
||||
that we create in the next step.
|
||||
|
@ -112,6 +112,9 @@ configure this app to use our SQL Server database, and then create a
|
|||
|
||||
This file defines the `web` and `db` micro-services, their relationship, the
|
||||
ports they are using, and their specific environment variables.
|
||||
|
||||
> **Note**: You may receive an error if you choose the wrong Compose file
|
||||
> version. Be sure to choose a verison that is compatible with your system.
|
||||
|
||||
1. Go to `Startup.cs` and locate the function called `ConfigureServices` (Hint:
|
||||
it should be under line 42). Replace the entire function to use the following
|
||||
|
|
Loading…
Reference in New Issue