How to install and use Docker in Windows systems

How to install and use Docker in Windows systems

Docker is a containerization technology that allows developers to package applications and their dependencies into a portable container for rapid deployment and operation. In Windows systems, Docker can be installed and used through the following steps.

advantage:

Docker is an open platform for developing, delivering and running applications. Docker enables you to separate applications from infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure the same way you manage your applications. By leveraging Docker's approach to quickly delivering, testing, and deploying code, you can significantly reduce the delay between writing code and running it in production.

Application scenarios:

  • Automated packaging and publishing of web applications.
  • Automated testing and continuous integration and release.
  • Deploy and tune databases or other back-end applications in service-based environments.
  • Build your own PaaS environment by compiling from scratch or extending an existing OpenShift or Cloud Foundry platform.

Install Docker

Environmental preparation

Docker for Windows is a Docker Community Edition (CE) application. The Docker for Windows installation package contains everything you need to run Docker on Windows systems. If you don't want to install a virtual machine and want to install and learn to use Docker directly in your Windows operating system, you first need to check whether the system meets the installation and use requirements of Docker for Windows. as follows:

1. The current version of Docker for Windows runs on 64-bit Windows 10 Pro, Professional, Enterprise and Education editions. (Home version is not supported) 2. Check whether the virtualization of the computer is turned on: Right-click the start button in the lower left corner of the computer->Task Manager->Performance->cpu, check whether virtualization is enabled, if virtualization is displayed as disabled, you need to restart Enter the BIOS of the computer and enable virtualization (by Baidu, the method is different without a computer) 3. After enabling virtualization and restarting, check again whether virtualization is enabled in the task manager.
Insert image description here
4. Left-click the Start button in the lower left corner of the computer -> Click "Settings" -> Search for "Windows Features" -> Enable or turn off Windows features -> Check Hyper-v. After enabling it, the computer will restart and the installation environment is configured successfully.
Insert image description here
Insert image description here

download

Download address
https://docs.docker.com/desktop/install/windows-install/#download-docker-for-windows
Insert image description here

Install

  1. Once the installation is complete, open the Docker Desktop application. In the system tray, you can see the Docker icon.

  2. Click the Docker icon, select the "Settings" menu, and enter the Docker settings page. In the "General" tab, you can set Docker's startup items and exit items.

  3. In the "Resources" tab, you can set Docker's CPU and memory usage.

  4. In the "Advanced" tab, you can set Docker's network and proxy settings.

Using Docker

  1. Open a command line terminal and enter the following command to verify whether Docker is installed correctly:

    docker version
    

    If installed correctly, Docker version information will be displayed.
    Insert image description here

  2. Download the Docker image. A Docker image is an executable package that contains an application and its dependencies. You can download the image from Docker Hub, or you can use Dockerfile to custom build the image.

    docker pull [image name]
    

    For example, download the Ubuntu image:

    docker pull ubuntu
    
  3. Run the Docker container. A container is an instance of a Docker image in which an application can be run.

    docker run [image name]
    

    For example, running an Ubuntu container:

    docker run -it ubuntu
    

    In a container, various commands can be executed, such as installing packages, running scripts, etc.

  4. Exit the Docker container. You can exit the container using the following command:

    exit
    

    Or stop the container using the following command:

    docker stop [container name or ID]
    

    For example, to stop an Ubuntu container:

    docker stop [container name or ID]
    

3-Common configurations of docker

Set tab key auto-completion in PowerShell
1. Start a PowerShell (run as administrator). Search for PowerShell, right-click and select Run as administrator. At the PowerShell prompt type:

Set-ExecutionPolicy RemoteSigned

2. Check whether the policy settings are correct and run:

get-executionpolicy

3. Install the posh-docker PowerShell module to automate Docker commands, type: Install-Module posh-docker Alternatively, to install the module only for the current user, type:

Install-Module -Scope CurrentUser posh-docker

4. After the installation is complete, the auto-complete function can only be enabled for the current PowerShell, enter:

Import-Module posh-docker

Settings
Find the docker icon in the lower right corner, right-click and select settings
1. General: Here is the setting for docker to start automatically at boot, check for updates when the application starts, and publish usage statistics
Insert image description here
2. Advanced: allocate the number of CPUs and memory
Insert image description here

Guess you like

Origin blog.csdn.net/qq_37480069/article/details/130408909