Docker for Windows

Source: Internet
Author: User
Tags virtual environment docker run docker toolbox

Introduction to Docker for Windows use

In the previous article, the process of running an ASP. NET Core Web API application in Docker was described in the walkthrough Guide. This article describes the use of Docker for Windows.

Prerequisite

In the first two weeks, Docker released the full version of Docker for Windows, so that it could run the Docker container under Windows. To run Docker under Windows, you need to meet the following prerequisites:

    • 64-bit Windows Pro, enterprise or education version (build 10586 or later, need to install 1511 November update)
    • Enable Hyper-V in the system. If not enabled, Docker for Windows automatically enables Hyper-V during installation (this process requires a system restart)

However, if you are not using Windows 10, there is no relationship, and you can use Docker Toolbox as an alternative.

Installation and use of Docker for Windows

In Windows 10, click here to download the Docker for Windows installation package, and then start the installation. As described above, if Hyper-V is not enabled, the installation process automatically enables Hyper-V, which will require a restart of the Windows system. Once the installation is complete, you can use Docker under Windows.

Starting Docker for Windows displays a small whale icon in the System Tray section:. Before the Docker is fully booted, the small squares on the back of the little whale will constantly blink and wait until the small squares stabilize, indicating that the system is fully successful, and that the Docker environment can be set or the Docker command will be started.

Settings for the Docker environment

Right-click the small whale icon on the system tray and select the Settings menu:

This opens the Settings dialog box:

This dialog box contains the configuration for the virtual environment that runs Docker Daemon, and the configuration for the Docker daemon. Including:

    • Shared Drivers: You can share drives in a host (that is, a Windows machine) in a Docker container
    • Advanced: For configuring the CPU and memory of a virtual environment running Docker Daemon
    • Network: Configuring Docker's networking Environment
    • Proxies: Configuration of the agent
    • Docker Daemon: Configuring Docker Daemon with JSON-formatted settings, similar to configuring Docker with Conf files in a Linux environment

In fact, the installation of Docker for Windows creates a Linux virtual machine for running Docker daemon in Hyper-V, and many of the configurations in this dialog box are configured for that virtual machine. When the configuration changes, Docker for Windows restarts (small cubes on the back of the little whale will move again), which is the process of dynamically adjusting and restarting the configuration of this Linux virtual machine. For example, as you can see, I set my own Docker to 1 CPUs and 1GB of memory, and this configuration is applied to this virtual machine on Hyper-V:

If you install Docker Toolbox in a pre-Windows 10 version of Windows, you need to ensure that your Windows system supports hardware virtualization technology (HVT):

    • If you are using Windows 8 or 8.1: In Task Manager, select the "Performance" tab, and then in the CPU column, see if "Virtualization" (virtualization) is enabled
    • If Windows 7, download and execute the Microsoft hardware-assisted virtualization Detection tool to see if your system meets the criteria

Also, you need to make sure that the Windows system is 64-bit. For more information on Docker Toolbox, please refer to the official website for detailed instructions.

Run the Docker command

After the Docker for Windows starts successfully, you can execute the Docker command at the Windows command prompt, or you can execute the Docker command in the power Shell to see a person's preference. The Docker CLI experience is the same as under Linux.

Using Docker for Windows to run ASP. NET Core Web API applications in containers

We still use the ASP. NET Core Web API application published in the previous article, and still use that Dockerfile file. Now, first make sure that the Dockerfile file is in the same directory as the file for the published DOCKERWEBAPI application:

Then execute:

1 docker build -t daxnet/docker-webapi .

You will see the following results (of course, it has been done before, so basically every step of the image is taken from the cache):

There is a security warning here compared to compiling Docker image under Linux. This is because we are compiling the build of the image using the Docker service deployed in non-Windows under Windows, and the file permission settings are different in both sets of systems. Docker for Windows recommends checking the file's permissions on the compiled generated image to ensure security.

Next, test the Docker Image that you just generated. Perform:

1 docker run -it -p 8080:5000 daxnet/docker-webapi

You will get the following effect:

Test it:

Effect the same as an article before.

Summarize

This article provides a brief introduction to Docker for Windows and uses the case of the previous article to run the ASP. NET Core Web API application on Docker for Windows. I'll also cover some of the things that Docker uses later, and will continue to use the ASP. NET Core Web API to explain the containerized (dockerization) and deployment of restful services.

Docker for Windows

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.