Docker Integration for Visual Studio Developers

Containerization using Docker

As implementation of solutions based on micro services and containerization are growing like never before, it is important for us to weigh the advantages.  As we know, Docker in this area has gone way ahead of others. Even though it evolved as a container solution based on Linux, of late native support for Docker has been released in Windows Server 2016 and Windows 10 OS.

Docker for Visual Studio Developers

dockerVSfeature

Support for Docker is available in Visual Studio 2017. To build, run and debug your applications from VS in Docker container, you should install Docker for Windows (https://docs.docker.com/docker-for-windows/install/) installed on your PC in addition to Visual Studio 2017.

Once installed, you can specify the option as below to enable Docker support while creating your project. Alternately you can right click on the particular project in solution explorer and use Add->Docker Support.

Docker

Visual studio integration adds the following files to your project

  • Dockerfile – build instructions for the image

Compose Files (to define and run multi-container applications with Docker)

  • Docker-compose.yml
  • Docker-compose.dev.debug.yml
  • Docker-compose.dev.release.yml

The docker-compose.yml file contains the name of the image that is created when project is run

version: '2'
services:
 ci-build:
 image: microsoft/aspnetcore-build:1.1.0-msbuild
 volumes:
 - .:/src
 working_dir: /src
 command: /bin/bash -c "dotnet restore && dotnet publish -c Release -o ./bin/Release/PublishOutput"

Sample Dockerfile

FROM microsoft/aspnetcore:1.1
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "MyDockerApplication.dll"]
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s