-
Notifications
You must be signed in to change notification settings - Fork 592
03. Publishing your Windows Container images into a Docker Registry
When deploying a Docker container into production environments (including Windows Containers and Linux containers), you need to deploy it by pulling its related Docker image ("docker pull") from a Docker Registry, in the first place. After that, you'll be able to deploy it to multiple environments like a regular Docker Host (VM), Azure Container Instances, Kubernetes, Service Fabric, Azure App Service, etc.
But the common denominator that you need to use is a Docker Registry. When you are creating a custom application which will be running as a container, you also need to know how to create its related custom Docker image and how to publish that image into a Docker Registry.
This walkthrough assumes a basic understanding of Docker. You can learn about Docker by reading the Docker Overview.
This post describes how to create a custom eShopModernizedMVC Windows Container image (Docker image for Windows Containers) in your local development PC with Visual Studio and 'Docker for Windows' installed and then how to publish it into a Docker Registry.
A Docker Registry is a public or private store, running on a public cloud or on-premises, which contains Docker container images, either for Linux or Windows. An example od a Docker Registry is 'Docker Hub' and 'Azure Container Registry'. Both are public registries and both allow private repositories of images.
A few examples of a Docker registry and its related taxonomy is shown below.
Publishing your custom Docker images in a Docker Registry requires a 2-step process:
- Create your custom Docker image (Windows Container image, in this case)
- Publish/Push your custom Docker image into a Docker Registry (i.e. Docker Hub or Azure Container Registry)
You can also do the same action but in an automated way from your CI or build pipelines like in Visual Studio Team Services (VSTS) or Jenkins.
As explained in the previous post titled "How to containerize the .NET Framework web apps with Windows Containers and Docker", the following image shows you the environment in your local development PC when creating and running your containers locally.
However, when you need to deploy your image as a container into production environments, you first need to publish/push your images into a Docker Registry (i.e. Docker Hub or Azure Container Registry) as in the following evolved figure.
This particular scenario focuses just on the area highlighted in yellow, meaning the steps on how you can create your custom Docker image and have it ready in your local development PC.
1. Confirm/change the name and tag of your custom image to create
Open the docker-compose.yml file and check the name of your custom image to be created. For instance, in the following .YML code it is named as eshop/modernizedmvc:4.7.1-windowsservercore-1709
, where eshop
has to coincide with the name of the repo or organization at the Docker Registry (such as Docker Hub), eshop/modernizedmvc
is the full name of the image, and :4.7.1-windowsservercore-1709
is a tag which can specify any characteristic of the image, like version, etc.
Common tags are: latest
, dev
, etc.
version: '3'
services:
eshop.modernized.mvc:
image: eshop/modernizedmvc:4.7.1-windowsservercore-1709
build:
context: .\src\eShopModernizedMVC
dockerfile: Dockerfile
depends_on:
- sql.data
sql.data:
image: microsoft/mssql-server-windows-developer
In our case, we're specifying the version of the ASP.NET base image microsoft/aspnet:4.7.1-windowsservercore-1709
we're using at the dockerfile
(such as the dockerfile within the eShopModernizedMVC project) because certain deployment environments might only support specific versions of Windows Server Core (1709 vs. older), so you can discriminate or select the right image.
2. Compile your .NET application bits and publish it in a local folder
In order to create a Windows Container image you first need to generate your .NET application's bits by compiling it and publishing in a local folder. In order to do so in Visual Studio, right click on the eShopModernized project and hit on the Publish
menu option as shown below.
Then, make sure that the selected profile is of type "FolderProfile" and very importantly, make sure that the target location is set to "obj\docker\publish" as that is the path where docker-compose build
will look for the compiled app's bits.
Once those settings are confirmed, hit on the Publish button.
From Visual Studio 2017 you can do both steps from the
XXXXXXXXXXX TO CONTINUE XXXXXXXXXX
NOTE ON DOCKER MULTI-STAGE BUILDS: In the near future when Docker Multi-Stage builds are supported in Windows Containers you won't need to first compile and publish the app's bits in a folder because with Docker Multi-Stage build when running docker-compose build/up it will also compile the .NET bits in a previous stage by using a .NET SDK/Build image and then it will generate the final app's image, all in a single docker-compose build execution. No need to compile/publish from Visual Studio.
Docker Multi-Stage builds are already supported for Linux containers as of April 2018.
************** TBD - VS Publish steps **************
Scenario 2: Publish/Push your Windows Container image into a Docker Registry (i.e. Docker Hub) using the Docker CLI
As mentioned, when you need to deploy your image as a container into production environments, you first need to publish/push your images into a Docker Registry (i.e. Docker Hub or Azure Container Registry).
This is precisely the scenario highlighted in yellow in the following figure.
************** TBD - docker push steps **************
- Home
- Release notes
- e-books
-
MVC & Web Forms Samples
- Tour of the "legacy" ASP.NET web apps to modernize
- How to containerize the .NET Framework web apps with Windows Containers and Docker
- Publishing your Windows Container images into a Docker Registry
- Deploying the Apps to Azure Web Apps for Containers
- Deploying the Apps to ACI (Azure Container Instances)
- Deploying your Windows Containers based app into Azure VMs (Including CI CD)
- Deploying into local Kubernetes in Windows 10 and Docker for Windows development environment
- How to deploy your Windows Containers based apps into Kubernetes in Azure Container Service (Including CI CD)
- How to add authentication authorization with Azure Active Directory
- How to migrate the SQL database to Azure with the Azure Database Migration Service
- Using Application Insights in eShopOnContainers
- N-Tier sample: WinForms app and WFC service
- ASP.NET to Azure App Service Migration Workshop