Visual Studio 2017 debugging Windows Server Docker Container

Source: Internet
Author: User
Tags docker for mac docker ps docker compose docker toolbox

Many articles on the web are deployed with Docker for Windows tools under WIN10. With Windows Server 2016 already natively supported Docker, its Windows container is already consistent with kernel technology under Linux, and the most important reason is that the deployment of a Docker container must be in Windows Server Above the. So why not try a fresh one and build a Visual Studio 2017来 directly with Windows Server 2016.

One, Windows Server 2016 installs Docker

Installing Docker on Windows Server 2016 is easy, and you don't need to install a dokcer for Windows tool like Win10, and you don't need to open hyper-V to build a Linux virtual machine. Run the following command directly below the shell command:

Install-module-name dockermsftprovider-repository psgallery-forceinstall-package-name Docker-  ProviderName Dockermsftproviderrestart-computer-force

You can refer to Windows Containers on Windows Server

After restarting the computer, running Docker version will pop up the following interface, indicating that Docker is installed

Second, enable Docker support on the ASP. NET WEB Application project (Note:

Create a new ASP. NET WEB Application project using visual Studio 2017

Choose one on the template, unlike the. NET core program, which has direct option to enable Docker support

It doesn't matter, we can right-click on the project vs2017-"add-" Docker support

The following files will be

Basically, Docker-compose and dockerfile are building docker containers.

Third, enable Docker debugging

If you press F5 to select Docker for debugging, there will be an error, mainly the Docker-compose command not found. The following is found on the Docker website:

Docker for Mac, Docker for Windows, and Docker Toolbox include Docker Compose, so most Macs and Windows users do not need t o Install Docker Compose separately.

If You is running the Docker daemon and client directly on Microsoft Windows Server (with Docker EE for Windows Serv ER), you does need to install Docker Compose.

To does this, the start an "elevated" PowerShell (run it as Administrator). Search for PowerShell, right-click, and choose Run as Administrator. When the asked if you want the this app to make changes to your device, click Yes.

Run the following command to download Docker Compose, replacing with the $dockerComposeVersion specific version of Compose your want to use :


-OutFile $Env:ProgramFiles\docker\docker-compose.exe

For example, to download Compose version 1.12.0, the command is:

none Invoke-WebRequest "https://github.com/docker/compose/releases/download/1.12.0/docker-compose-Windows-x86_64.exe" -UseBasicParsing -OutFile $Env:ProgramFiles\docker\docker-compose.exe

Now, run the executable to install Compose.

Reference: Install Docker Compose, let's find the latest version of Docker-compose https://github.com/docker/compose/releases, Found to be 1.13.0, then that sentence can be changed directly to

" Https://github.com/docker/compose/releases/download/1.13.0/docker-compose-Windows-x86_64.exe " $Env:P rogramfiles\docker\docker-compose.exe

Full of anticipation to run F5, the result is still error:

Error:client version 1.22 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

Check it out, originally if you use Docker 1.13 or above, you need to docker-compose.yml version: ‘2‘ change it to the version version: ‘2.1‘ here.

Really is twists, finally is no problem, compile also can pass. But when debugging F5, but it happens to have remote debugging errors ...

This time, run the Docker PS command and you can see that our container has started

Let's take a look at the container IP

$CONTAINER _id

Then access directly in the browser, you can already see the site is running.

This is really a pit of the place, there is no relevant information on the Internet, but in StackOverflow found related issues: Running Visual Studio Remote Debugger in Windows Container (Docker managed) , but it doesn't work. Finally think for a while, the original server version of the limit is relatively high, you must develop the port in the firewall, or directly shut down the firewall, OK.

Reference:

BUILD and RUN YOUR first DOCKER WINDOWS SERVER CONTAINER

Docker's first experience with Windows containers

debugging of an ASP. NET Core Web API application in a Docker container environment

Visual Studio 2017 debugging Windows Server Docker Container

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.