зеркало из https://github.com/docker/labs.git
Update to Windows Server 2019
Signed-off-by: Elton Stoneman <elton@sixeyed.com>
This commit is contained in:
Родитель
e952389a5f
Коммит
f9b8a44224
|
@ -2,16 +2,16 @@
|
|||
|
||||
This tutorial walks you through building and running the sample Album Viewer application with Windows containers. The [Album Viewer](https://github.com/RickStrahl/AlbumViewerVNext) app is an ASP.NET Core application, maintained by Microsoft MVP [Rick Strahl](https://weblog.west-wind.com). There is a fork at [dockersamples/dotnet-album-viewer](https://github.com/dockersamples/dotnet-album-viewer "link to forked version of Album Viewer") which uses Docker Windows containers.
|
||||
|
||||
> Docker isn't just for new apps built with .NET Core. You can run full .NET Framework apps in Docker Windows containers, with production support in [Docker EE](https://www.docker.com/enterprise-edition). Check out the labs for [Modernizing .NET apps with Docker](https://github.com/docker/labs/tree/master/windows/modernize-traditional-apps).
|
||||
> Docker isn't just for new apps built with .NET Core. You can run full .NET Framework apps in Docker Windows containers, with production support in [Docker Enterprise](https://www.docker.com/enterprise-edition). Check out the labs for [Modernizing .NET apps with Docker](https://github.com/docker/labs/tree/master/windows/modernize-traditional-apps).
|
||||
|
||||
## Using Docker Compose on Windows
|
||||
|
||||
[Docker Compose](https://docs.docker.com/compose/) is a great way develop distributed applications, where all the components run in their own containers. In this lab you'll use Docker Compose to run SQL Server in a container, as the data store for an ASP.NET Core web application running in another container.
|
||||
|
||||
Docker Compose is installed with [Docker for Windows](https://www.docker.com/docker-windows). If you've installed Docker as a Windows Service instead, you can download the compose command line using PowerShell:
|
||||
Docker Compose is installed with [Docker Desktop on Windows 10](https://www.docker.com/docker-windows). If you've installed the Docker Engine as a Windows Service instead, you can download the compose command line using PowerShell:
|
||||
|
||||
```
|
||||
Invoke-WebRequest https://github.com/docker/compose/releases/download/1.16.0/docker-compose-Windows-x86_64.exe -UseBasicParsing -OutFile $env:ProgramFiles\docker\docker-compose.exe
|
||||
Invoke-WebRequest https://github.com/docker/compose/releases/download/1.23.2/docker-compose-Windows-x86_64.exe -UseBasicParsing -OutFile $env:ProgramFiles\docker\docker-compose.exe
|
||||
```
|
||||
|
||||
To run the sample application in multiple Docker Windows containers, start by cloning the GithUb [dockersamples/dotnet-album-viewer](https://github.com/dockersamples/dotnet-album-viewer/) repository:
|
||||
|
@ -27,7 +27,7 @@ cd dotnet-album-viewer
|
|||
docker-compose build
|
||||
```
|
||||
|
||||
You'll see a lot of output here. Docker will pull the .NET Core images if you don't already have them, then it will run `dotnet restore` and `dotnet build` inside a container. You will see the usual NuGet and MSBuild output, even if you don't have the SDK installed.
|
||||
You'll see a lot of output here. Docker will pull the .NET Core images if you don't already have them, then it will run `dotnet restore` and `dotnet build` inside a container. You will see the usual NuGet and MSBuild output - you don't need to have the .NET Core SDK installed, because it is part of the Docker image.
|
||||
|
||||
When the build completes, run the app with:
|
||||
|
||||
|
@ -35,33 +35,24 @@ When the build completes, run the app with:
|
|||
docker-compose up -d
|
||||
```
|
||||
|
||||
Docker starts a database container using Microsoft's [SQL Server Express Windows image](https://store.docker.com/images/mssql-server-windows-express), and when the database is running it starts the application container. The database and application containers are in the same Docker network, so they can reach each other.
|
||||
Docker starts a database container using [TiDB](https://github.com/pingcap/tidb), which is a modern distributed database system compatible with MySQL. When the database is running it starts the application container. The database and application containers are in the same Docker network, so they can reach each other.
|
||||
|
||||
The container for the web application maps to port 80 on the host, so from a different machine you can browse to your host address and see the site:
|
||||
The container for the web application publishes port 80 on the host, so you can browse to your http://localhost and see the site:
|
||||
|
||||
![ASP.NET Core Album Viewer app running in a Docker Windows container](images/dotnet-album-viewer.png)
|
||||
|
||||
If you're working on the host, you need to browse to the container's IP address. You can find it with `docker container inspect`:
|
||||
|
||||
```
|
||||
docker container inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" dotnetalbumviewer_app_1
|
||||
172.21.124.54
|
||||
```
|
||||
|
||||
### Organizing Distributed Solutions with Docker Compose
|
||||
|
||||
Take a closer look at the [docker-compose.yml](https://github.com/dockersamples/dotnet-album-viewer/blob/master/docker-compose.yml) file. There are two [services](https://docs.docker.com/compose/compose-file/#service-configuration-reference) defined, which are the different components of the app that will run in Docker containers. The first is the SQL Server database:
|
||||
Take a closer look at the [docker-compose.yml](https://github.com/dockersamples/dotnet-album-viewer/blob/master/docker-compose.yml) file. There are two [services](https://docs.docker.com/compose/compose-file/#service-configuration-reference) defined, which are the different components of the app that will run in Docker containers. The first is the MySQL-compatible database:
|
||||
|
||||
```
|
||||
db:
|
||||
image: microsoft/mssql-server-windows-express
|
||||
environment:
|
||||
sa_password: "DockerCon!!!"
|
||||
ACCEPT_EULA: "Y"
|
||||
image: dockersamples/tidb:nanoserver-1809
|
||||
ports:
|
||||
- "3306:4000"
|
||||
```
|
||||
|
||||
This uses Microsoft SQL Server Express, which runs as a Docker Windows container. Express edition has a production licence, so you can use it for live applications. The environment settings configure the database, setting the password for the `sa` user account, and accepting the licence agreement.
|
||||
|
||||
The second service is the ASP.NET Core web application, which uses the custom image you built at the start of the lab:
|
||||
|
||||
```
|
||||
|
@ -70,42 +61,40 @@ The second service is the ASP.NET Core web application, which uses the custom im
|
|||
build:
|
||||
context: .
|
||||
dockerfile: docker/app/Dockerfile
|
||||
environment:
|
||||
- "Data:useSqLite=false"
|
||||
- "Data:SqlServerConnectionString=Server=db;Database=AlbumViewer;User Id=sa;Password=DockerCon!!!;MultipleActiveResultSets=true;App=AlbumViewer"
|
||||
depends_on:
|
||||
- db
|
||||
ports:
|
||||
- "80:80"
|
||||
environment:
|
||||
- "Data:Provider=MySQL"
|
||||
- "Data:ConnectionString=Server=db;Port=4000;Database=AlbumViewer;User=root;SslMode=None"
|
||||
depends_on:
|
||||
- db
|
||||
```
|
||||
|
||||
The [build](https://docs.docker.com/compose/compose-file/#build) details capture the path to the Dockerfile. The environment variables are used to configure the app - they override the settings in [appsettings.json](https://github.com/dockersamples/dotnet-album-viewer/blob/master/src/AlbumViewerNetCore/appsettings.json). This configuration uses SQL Server rather than the default SQLite database, and sets the connection string to use the SQL Server container.
|
||||
The [build](https://docs.docker.com/compose/compose-file/#build) details capture the path to the Dockerfile. The environment variables are used to configure the app - they override the settings in [appsettings.json](https://github.com/dockersamples/dotnet-album-viewer/blob/master/src/AlbumViewerNetCore/appsettings.json). This configuration uses MySQL rather than the default SQLite database, and sets the connection string to use the TiDB database container.
|
||||
|
||||
> In the database connection string, the server name is `db` - which is the name of the service for the SQL container. Docker has service discovery built-in, so when the app tries to connect using the server name `db`, Docker will direct it to the database container.
|
||||
> The database container has a built-in user called `root` with no password, and this is the account used by the web application in the connection string.
|
||||
|
||||
The app definition also captures the [dependency](https://docs.docker.com/compose/compose-file/#depends_on) on the database server, and publishes port 80 so any traffic coming into the host gets directed by Docker into the container.
|
||||
|
||||
|
||||
## Packaging ASP.NET Core apps in Docker
|
||||
|
||||
How can you compile and run this app without .NET Core installed? Docker compiles and runs the app using containers. The tasks are in the [Dockerfile](https://github.com/dockersamples/dotnet-album-viewer/blob/master/docker/app/Dockerfile), which captures all the app dependencies so the only pre-requisite you need is Docker. The first stage in the Dockerfile publishes the app:
|
||||
How can you compile and run this app without .NET Core installed? Docker compiles and runs the app using containers. The tasks are in the [Dockerfile](https://github.com/dockersamples/dotnet-album-viewer/blob/master/docker/app/Dockerfile), which captures the app dependencies so the only pre-requisite you need is Docker. The first stage in the Dockerfile publishes the app:
|
||||
|
||||
```
|
||||
FROM microsoft/dotnet:2.0.0-sdk-nanoserver AS builder
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
FROM microsoft/dotnet:2.1-sdk-nanoserver-1809 AS builder
|
||||
|
||||
WORKDIR /album-viewer
|
||||
COPY AlbumViewerNetCore.sln .
|
||||
COPY src/AlbumViewerNetCore/AlbumViewerNetCore.csproj src/AlbumViewerNetCore/AlbumViewerNetCore.csproj
|
||||
COPY src/AlbumViewerBusiness/AlbumViewerBusiness.csproj src/AlbumViewerBusiness/AlbumViewerBusiness.csproj
|
||||
COPY src/Westwind.Utilities/Westwind.Utilities.csproj src/Westwind.Utilities/Westwind.Utilities.csproj
|
||||
RUN dotnet restore
|
||||
RUN dotnet restore src/AlbumViewerNetCore/AlbumViewerNetCore.csproj
|
||||
|
||||
COPY src src
|
||||
RUN dotnet publish .\src\AlbumViewerNetCore\AlbumViewerNetCore.csproj
|
||||
```
|
||||
|
||||
This uses Microsoft's [.NET Core Docker image](https://store.docker.com/images/dotnet) as the base in the `FROM` instruction. It uses a specific version of the image, with the .NET Core 2.0.0 SDK installed, running on Microsoft Nano Server. Then the `COPY` instructions copy the project files and solution files into the image, and the `RUN` instruction executes `dotnet restore` to restore packages.
|
||||
This uses Microsoft's [.NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet) as the base in the `FROM` instruction. It uses a specific version of the image, with the .NET Core 2.1 SDK installed, running on the 1809 release of Microsoft Nano Server. Then the `COPY` instructions copy the project files and solution files into the image, and the `RUN` instruction executes `dotnet restore` to restore packages.
|
||||
|
||||
Docker caches parts of the image as it build them, and this Dockerfile separates out the restore part to take advantage of that. Unless the solution or project files change, Docker will re-use the image layer with the dependencies already restored, saving time on the `dotnet restore` operation.
|
||||
|
||||
|
@ -115,18 +104,16 @@ The final stage in the Dockerfile packages the published application:
|
|||
|
||||
```
|
||||
# app image
|
||||
FROM microsoft/aspnetcore:2.0.0-nanoserver
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1809
|
||||
|
||||
WORKDIR /album-viewer
|
||||
COPY --from=builder /album-viewer/src/AlbumViewerNetCore/bin/Debug/netcoreapp2.0/publish/ .
|
||||
CMD ["dotnet", "AlbumViewerNetCore.dll"]
|
||||
```
|
||||
|
||||
This uses a different base image, which is optimized for running [ASP.NET Core](https://store.docker.com/community/images/microsoft/aspnetcore) apps. It has the .NET Core runtime, but not the SDK, and the ASP.NET core packages are already installed. The `COPY` instruction copies the published .NET Core app from the previous stage in the Dockerfile (called `builder`), and the `CMD` instruction tells Docker how to start the app.
|
||||
|
||||
The Dockerfile syntax is simple. You only need to learn a handful of instructions to build production-grade Docker images. Inside the Dockerfile, you can use PowerShell to deploy MSIs, update Windows Registry settings, set file permissions and do anything else you need.
|
||||
This uses a different variant of the `dotnet` base image, which is optimized for running ASP.NET Core apps. It has the .NET Core runtime, but not the SDK, and the ASP.NET core packages are already installed. The `COPY` instruction copies the published .NET Core app from the previous stage in the Dockerfile (called `builder`), and the `CMD` instruction tells Docker how to start the app.
|
||||
|
||||
The Dockerfile syntax is simple. You only need to learn a handful of instructions to build production-grade Docker images. Inside the Dockerfile you can use PowerShell to deploy MSIs, update Windows Registry settings, set file permissions and do anything else you need.
|
||||
|
||||
## Next Steps
|
||||
|
||||
|
|
|
@ -1,14 +1,58 @@
|
|||
## Getting Started with Windows Containers
|
||||
# Getting Started with Windows Containers
|
||||
|
||||
In September 2016, Microsoft announced the general availability of Windows Server 2016, and with it, Docker engine running containers natively on Windows. This tutorial describes how to get setup to run Docker Windows Containers on Windows 10 or using a Windows Server 2016 VM.
|
||||
Docker containers run natively in Windows Server 2016, Windows Server 2019 and Windows 10. These labs are based on the latest releases of Windows and Docker which provide the best experience for containerized Windows applications.
|
||||
|
||||
If you are developing locally, you must be running Windows 10 pro or Windows 2016 in a virtual machine to be able to use this tutorial.
|
||||
The minimum requirements are:
|
||||
|
||||
If you're using a cloud VM, you must use Windows 2016 VM.
|
||||
* Windows 10 Professional or Enterprise, with Windows update 1809 *or*
|
||||
* Windows Server 2019
|
||||
|
||||
## Step 1 - Setup
|
||||
|
||||
You can run Windows containers on Windows 10, Windows Server 2016 and Windows Server 2019:
|
||||
|
||||
+ [Install Docker Desktop on Windows 10](https://hub.docker.com/editions/community/docker-ce-desktop-windows "Windows 10 Setup")
|
||||
+ [Install Docker Enterprise Engine on Windows Server](https://hub.docker.com/editions/enterprise/docker-ee-server-windows "Setup on Windows Server")
|
||||
|
||||
> Most public cloud providers also have a VM image with Docker already installed. You can use Microsoft's **Windows Server 2019 Datacenter with Containers** VM image on Azure, and Amazon's **Microsoft Windows Server 2019 Base with Containers** AMI on AWS.
|
||||
|
||||
## Verification
|
||||
|
||||
Run `docker version` to check the basic details of your deployment. You should see "Windows" listed as the operating system for the Docker client and the Docker Engine:
|
||||
|
||||
```
|
||||
PS>docker version
|
||||
Client: Docker Engine - Community
|
||||
Version: 18.09.1
|
||||
API version: 1.39
|
||||
Go version: go1.10.6
|
||||
Git commit: 4c52b90
|
||||
Built: Wed Jan 9 19:34:26 2019
|
||||
OS/Arch: windows/amd64
|
||||
Experimental: false
|
||||
|
||||
Server: Docker Engine - Community
|
||||
Engine:
|
||||
Version: 18.09.1
|
||||
API version: 1.39 (minimum version 1.24)
|
||||
Go version: go1.10.6
|
||||
Git commit: 4c52b90
|
||||
Built: Wed Jan 9 19:50:10 2019
|
||||
OS/Arch: windows/amd64
|
||||
Experimental: true
|
||||
```
|
||||
|
||||
> The `OS/Arch` field tells you the operating system and CPU architecture you're using. Docker is cross-platform, so you can manage Windows Docker servers from a Linux client and vice-versa, using the same `docker` commands.
|
||||
|
||||
## Windows Versions
|
||||
|
||||
The latest release of Windows to support Docker containers is Windows Server 2019, and Windows 10 with the 1809 update. There are many enhancements from the original Windows containers release in Server 2016.
|
||||
|
||||
> [Read about the new container features with Docker on Windows Server 2019](https://blog.docker.com/2019/01/announcing-support-for-windows-server-2019-within-docker-enterprise/)
|
||||
|
||||
Windows containers need to match the version of the OS where the container is running with the version of the OS inside the container. Container images flagged as `ltsc2019` or `1809` work with the latest Windows versions.
|
||||
|
||||
|
||||
This tutorial consists of three parts:
|
||||
## Next Steps
|
||||
|
||||
1. [Setup](Setup.md "Setup"): Making sure your development environment is properly set-up to work with Windows Containers.
|
||||
2. [Getting Started with Windows Containers](WindowsContainers.md "Getting Started with Windows Containers"): The basics of Windows Containers.
|
||||
3. [Multi-Container Applications](MultiContainerApp.md "Multi-Container Applications"): Using [Docker Compose](https://docker.github.io/compose/ "Docker Compose") to launch a website based on Microsoft SQL Server.
|
||||
Continue to Step 2: [Getting Started with Windows Containers](WindowsContainers.md "Getting Started with Windows Containers")
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
# Setup - AWS
|
||||
|
||||
This chapter explores setting up a Windows environment to properly use Windows containers on Amazon Web Services (AWS).
|
||||
|
||||
|
||||
## Windows Server 2016 on AWS
|
||||
|
||||
AWS has a pre-baked AMI with Docker Engine already installed. To start an instance, do the following (requires AWS account):
|
||||
|
||||
1. Open the [EC2 launch-instance wizard](https://us-west-1.console.aws.amazon.com/ec2/v2/home#LaunchInstanceWizard)
|
||||
2. Select the "Microsoft Windows Server 2016 Base with Containers" AMI
|
||||
3. Input setup parameters
|
||||
- `c4.large` has good performance for development and testing
|
||||
- The default AWS security group settings will let you connect with Remote Desktop
|
||||
4. Select "Review and Launch"
|
||||
5. Once the VM is up, hit "Connect". If using macOS, get the free [Remote Desktop app in the Mac App Store](https://itunes.apple.com/us/app/microsoft-remote-desktop/id715768417?mt=12)
|
||||
6. See details on [getting the initial Windows Administrator password for your AWS instance](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/connecting_to_windows_instance.html)
|
||||
7. Start PowerShell
|
||||
8. Check that Docker is running with `docker version`
|
||||
|
||||
![Connecting to AWS Virtual Machine](images/aws-connect.PNG)
|
||||
|
||||
|
||||
# Next Steps
|
||||
See the [Microsoft documentation for more comprehensive instructions](https://msdn.microsoft.com/virtualization/windowscontainers/containers_welcome "Microsoft documentation").
|
||||
|
||||
Continue to Step 2: [Getting Started with Windows Containers](WindowsContainers.md "Getting Started with Windows Containers")
|
|
@ -1,30 +0,0 @@
|
|||
# Setup - Azure
|
||||
|
||||
This chapter explores setting up a Windows environment to properly use Windows containers on Microsoft Azure.
|
||||
|
||||
|
||||
## Windows Server 2016 on Azure
|
||||
|
||||
Microsoft Azure has a pre-baked VM image with Docker engine and base images pre-loaded. To get started (requires Azure account):
|
||||
|
||||
1. Create a [Windows Server 2016 Datacenter - with Containers](https://azure.microsoft.com/en-us/marketplace/partners/microsoft/windowsserver2016datacenterwithcontainers/) VM. This VM image has Docker pre-installed and the Windows base layers pre-loaded.
|
||||
2. Select "Classic" deployment model and hit "Create"
|
||||
3. Input setup parameters
|
||||
- Default settings are good
|
||||
- Creating a new resource group is fine
|
||||
- `DS2_V2` instance type has good performance for development and testing
|
||||
4. Check the Summary and hit "OK". Setup will take a couple of minutes
|
||||
5. Once the VM is running, select "Connect" to open a remote desktop connection. If using macOS, get the free [Remote Desktop app in the Mac App Store](https://itunes.apple.com/us/app/microsoft-remote-desktop/id715768417?mt=12)
|
||||
6. Login with the username and password configured during setup
|
||||
7. Start PowerShell
|
||||
8. `Start-Service docker`
|
||||
9. Check that Docker is running with `docker version`
|
||||
|
||||
![Creating Azure Virtual Machine](images/Azure-ws2016-Create-Virtual-Machine.PNG)
|
||||
|
||||
![Connecting to Azure Virtual Machine](images/Azure-ws2016-Connect.PNG)
|
||||
|
||||
# Next Steps
|
||||
See the [Microsoft documentation for more comprehensive instructions](https://msdn.microsoft.com/virtualization/windowscontainers/containers_welcome "Microsoft documentation").
|
||||
|
||||
Continue to Step 2: [Getting Started with Windows Containers](WindowsContainers.md "Getting Started with Windows Containers")
|
|
@ -1,55 +0,0 @@
|
|||
# Setup - Windows Server 2016
|
||||
|
||||
This chapter explores setting up a Windows environment to properly use Windows containers on Windows Server 2016, on bare metal or in VM.
|
||||
|
||||
## Windows Server 2016 on bare metal or in VM
|
||||
|
||||
Windows Server 2016 is where Docker Windows containers should be deployed for production. For developers planning to do lots of Docker Windows container development, it may also be worth setting up a Windows Server 2016 dev system (in a VM, for example), at least until Windows 10 and Docker for Windows support for Windows containers matures. Running a VM with Windows Server 2016 is also a great way to do Docker Windows container development on macOS and older Windows versions.
|
||||
|
||||
Once Windows Server 2016 is running, log in, run Windows Update (use `sconfig` on Windows Server Core) to ensure all the latest updates are installed and install the Windows-native Docker Engine (that is, don't use "Docker for Windows"). There are two options: Install using a Powershell Package (recommended) or with DSC.
|
||||
|
||||
### PowerShell Package Provider (recommended)
|
||||
|
||||
Microsoft maintains a [PowerShell package provider](https://www.powershellgallery.com/packages/DockerMsftProvider) that lets easily install Docker on Windows Server 2016.
|
||||
|
||||
Run the following in an Administrative PowerShell prompt:
|
||||
|
||||
```
|
||||
Install-Module -Name DockerMsftProvider -Force
|
||||
Install-Package -Name docker -ProviderName DockerMsftProvider -Force
|
||||
Restart-Computer -Force
|
||||
```
|
||||
|
||||
### PowerShell Desired State Configuration
|
||||
|
||||
If interested in experimenting with [Windows PowerShell Desired State Configuration](https://msdn.microsoft.com/en-us/powershell/dsc/overview), Daniel Scott-Raynsford has built a [prototype script that uses DSC to install Docker Engine](https://www.powershellgallery.com/packages/Install-DockerOnWS2016UsingDSC/1.0.1/DisplayScript).
|
||||
|
||||
Here's how to use it:
|
||||
|
||||
```
|
||||
Install-Script -Name Install-DockerOnWS2016UsingDSC
|
||||
Install-DockerOnWS2016UsingDSC.ps1
|
||||
```
|
||||
|
||||
See Daniel's blog post for [details on installing Docker with DCS](https://dscottraynsford.wordpress.com/2016/10/15/install-docker-on-windows-server-2016-using-dsc/).
|
||||
|
||||
Whether using the PowerShell Package Provider or DSC, Docker Engine is now running as a Windows service, listening on the default Docker named pipe.
|
||||
|
||||
For development VMs running (for example) in a Hyper-V VM on Windows 10, it might be advantageous to make the Docker Engine running in the Windows Server 2016 VM available to the Windows 10 host:
|
||||
|
||||
# Open firewall port 2375
|
||||
netsh advfirewall firewall add rule name="docker engine" dir=in action=allow protocol=TCP localport=2375
|
||||
|
||||
# Configure Docker daemon to listen on both pipe and TCP (replaces docker --register-service invocation above)
|
||||
Stop-Service docker
|
||||
dockerd --unregister-service
|
||||
dockerd -H npipe:// -H 0.0.0.0:2375 --register-service
|
||||
Start-Service docker
|
||||
|
||||
The Windows Server 2016 Docker engine can now be used from the VM host by setting `DOCKER_HOST`:
|
||||
`$env:DOCKER_HOST = "<ip-address-of-vm>:2375"`
|
||||
|
||||
# Next Steps
|
||||
See the [Microsoft documentation for more comprehensive instructions](https://msdn.microsoft.com/virtualization/windowscontainers/containers_welcome "Microsoft documentation").
|
||||
|
||||
Continue to Step 2: [Getting Started with Windows Containers](WindowsContainers.md "Getting Started with Windows Containers")
|
|
@ -1,18 +0,0 @@
|
|||
# Setup - Windows 10
|
||||
|
||||
This chapter explores setting up a Windows environment to properly use Windows containers on Windows 10.
|
||||
|
||||
## Windows 10 with Anniversary Update
|
||||
|
||||
For developers, Windows 10 is a great place to run Docker Windows containers and containerization support was added to the Windows 10 kernel with the [Anniversary Update](https://blogs.windows.com/windowsexperience/2016/08/02/how-to-get-the-windows-10-anniversary-update/) (note that container images can only be based on Windows Server Core and Nanoserver, not Windows 10). All that’s missing is the Windows-native Docker Engine and some image base layers.
|
||||
|
||||
The simplest way to get a Windows Docker Engine is by installing the [Docker for Windows](https://docs.docker.com/docker-for-windows/ "Docker for Windows") public beta ([direct download link](https://download.docker.com/win/beta/InstallDocker.msi)). Docker for Windows used to only setup a Linux-based Docker development environment, but the public beta version now sets up both Linux and Windows Docker development environments, and we’re working on improving Windows container support and Linux/Windows container interoperability.
|
||||
|
||||
With the public beta installed, the Docker for Windows tray icon has an option to switch between Linux and Windows container development.
|
||||
|
||||
![Image of switching between Linux and Windows development environments](images/docker-for-windows-switch.gif "Image of switching between Linux and Windows development environments")
|
||||
|
||||
# Next Steps
|
||||
See the [Microsoft documentation for more comprehensive instructions](https://msdn.microsoft.com/virtualization/windowscontainers/containers_welcome "Microsoft documentation").
|
||||
|
||||
Continue to Step 2: [Getting Started with Windows Containers](WindowsContainers.md "Getting Started with Windows Containers")
|
|
@ -1,13 +0,0 @@
|
|||
# Setup
|
||||
|
||||
There are four environments you can use to set-up Windows Containers. We have provided separate guides for each:
|
||||
|
||||
+ [Windows 10 with the Anniversary Update](Setup-Win10.md "Windows 10 Setup")
|
||||
+ [Windows Server 2016 on Azure](Setup-Azure.md "MS Azure Setup")
|
||||
+ [Windows Server 2016 on AWS](Setup-AWS.md "AWS Setup")
|
||||
+ [Windows Server 2016 on bare metal or in VM](Setup-Server2016.md "Setup on Windows 2016")
|
||||
|
||||
# Next Steps
|
||||
See the [Microsoft documentation for more comprehensive instructions](https://msdn.microsoft.com/virtualization/windowscontainers/containers_welcome "Microsoft documentation").
|
||||
|
||||
After you have completed setup, you can continue to Step 2: [Getting Started with Windows Containers](WindowsContainers.md "Getting Started with Windows Containers")
|
|
@ -4,51 +4,28 @@ This chapter will cover the basics of using Windows Containers with Docker.
|
|||
|
||||
## Running Windows containers
|
||||
|
||||
First, make sure the Docker installation is working correctly by running `docker version`. The output should tell you the basic details about your Docker environment:
|
||||
First pull a Docker image which you can use to run a Windows container:
|
||||
|
||||
```
|
||||
> docker version
|
||||
Client:
|
||||
Version: 17.06.1-ee-1
|
||||
API version: 1.30
|
||||
Go version: go1.8.3
|
||||
Git commit: 4dd6e94
|
||||
Built: Sat Aug 12 01:34:13 2017
|
||||
OS/Arch: windows/amd64
|
||||
|
||||
Server:
|
||||
Version: 17.06.1-ee-1
|
||||
API version: 1.30 (minimum version 1.24)
|
||||
Go version: go1.8.3
|
||||
Git commit: 4dd6e94
|
||||
Built: Sat Aug 12 02:14:08 2017
|
||||
OS/Arch: windows/amd64
|
||||
Experimental: true
|
||||
```
|
||||
> The `OS/Arch` field tells you the operating system you're using. Docker is cross-platform, so you can manage Windows Docker servers from a Linux client and vice-versa, using the same `docker` commands.
|
||||
|
||||
Next, pull a Docker image which you can use to run a Windows container:
|
||||
|
||||
```
|
||||
docker image pull microsoft/windowsservercore
|
||||
docker image pull mcr.microsoft.com/windows/nanoserver:1809
|
||||
```
|
||||
|
||||
This downloads Microsoft's [Windows Server Core](https://store.docker.com/images/windowsservercore) Docker image onto your environment. That image is a full deployment of Windows Server 2016 Core edition (with no UI), packaged to run as a Docker container. You can use it as the base for your own apps, or you can run containers from it directly.
|
||||
This downloads Microsoft's [Nano Server](https://hub.docker.com/_/microsoft-windows-nanoserver) Docker image onto your environment. That image is a minimal Windows server operating system, packaged to run as a Docker container. You can use it as the base for your own apps, or you can run containers from it directly.
|
||||
|
||||
Try a simple container, passing a command for the container to run:
|
||||
|
||||
```
|
||||
docker container run microsoft/windowsservercore hostname
|
||||
69c7de26ea48
|
||||
PS> docker container run mcr.microsoft.com/windows/nanoserver:1809 hostname
|
||||
a33758b2dbea
|
||||
```
|
||||
|
||||
This runs a new container from the Windows Server Core image, and tells it to run the `hostname` command. The output is the machine name of the container, which is actually a random ID set by Docker. Repeat the command and you'll see a different host name every time.
|
||||
This runs a new container from the Windows Nano Server image, and tells it to run the `hostname` command. The output is the machine name of the container, which is actually a random ID set by Docker. Repeat the command and you'll see a different host name every time.
|
||||
|
||||
## Building and pushing Windows container images
|
||||
|
||||
You package your own apps in Docker by building a Docker image. You share the app by pushing the image to a registry - it could be a public registry like [Docker Cloud](https://cloud.docker.com), or a private registry running in your own environment like [Docker Trusted Registry](https://docs.docker.com/datacenter/dtr/2.0/). Anyone with access to your image can pull it and run containers - just like you did with Microsoft's public Windows Server Core image.
|
||||
You package your own apps in Docker by building a Docker image. You share the app by pushing the image to a registry - it could be a public registry like [Docker Hub](https://hub.docker.com), or a private registry running in your own environment like [Docker Trusted Registry](https://docs.docker.com/ee/dtr/). Anyone with access to your image can pull it and run containers - just like you did with Microsoft's public Windows Nano Server image.
|
||||
|
||||
Pushing images to Docker Cloud requires a [free Docker ID](https://cloud.docker.com/ "Click to create a Docker ID"). Storing images on Docker Cloud is a great way to share applications, or to create build pipelines that move apps from development to production with Docker.
|
||||
Pushing images to Docker Hub requires a [free Docker ID](https://hub.docker.com/ "Click to create a Docker ID"). Storing images on Docker Hub is a great way to share applications, or to create build pipelines that move apps from development to production with Docker.
|
||||
|
||||
Register for an account, and then save your Docker ID in a variable in your PowerShell session. We will use it in the rest of the lab:
|
||||
|
||||
|
@ -63,7 +40,7 @@ Docker images are built with the [docker image build](https://docs.docker.com/en
|
|||
You can generate a very simple Dockerfile with PowerShell:
|
||||
|
||||
```
|
||||
'FROM microsoft/windowsservercore' | Set-Content Dockerfile
|
||||
'FROM mcr.microsoft.com/windows/nanoserver:1809' | Set-Content Dockerfile
|
||||
'CMD echo Hello World!' | Add-Content Dockerfile
|
||||
```
|
||||
|
||||
|
@ -76,18 +53,18 @@ docker image build --tag $dockerId/hello-world .
|
|||
Run a container from the image, and you'll see it just executes the instruction from the `CMD` line:
|
||||
|
||||
```
|
||||
docker container run $dockerId/hello-world
|
||||
> docker container run $dockerId/hello-world
|
||||
Hello World!
|
||||
```
|
||||
|
||||
Now you have a Docker image for a simple Hello World app. The image is the portable unit - you can push the image to Docker Cloud, and anyone can pull it and run your app for themselves. First run `docker login` with your credentials, to authenticate with the registry. Then push the image:
|
||||
Now you have a Docker image for a simple Hello World app. The image is the portable unit - you can push the image to Docker Hub, and anyone can pull it and run your app for themselves. First run `docker login` with your credentials, to authenticate with the registry. Then push the image:
|
||||
|
||||
```
|
||||
docker image push $dockerId/hello-world
|
||||
```
|
||||
|
||||
Images stored on Docker Cloud are available in the web interface and public images can be pulled by other Docker users.
|
||||
Images stored on Docker Hub are available in the web interface, and public images can be pulled by other Docker users.
|
||||
|
||||
### Next Steps
|
||||
|
||||
Continue to Step 3: [Multi-Container Applications](MultiContainerApp.md "Multi-Container Applications"), to see how to build and run a web application which uses a SQL Server database - all using Docker Windows containers.
|
||||
Continue to Step 3: [Multi-Container Applications](MultiContainerApp.md "Multi-Container Applications"), to see how to build and run a web application which uses an ASP.NET Core web application and a SQL Server database - all using Docker Windows containers.
|
||||
|
|
Загрузка…
Ссылка в новой задаче