The foreword 0.

For other systems and versions, Docker is easy to install and can be found in the official tutorial: docs.docker.com/docker-hub/

Because Windows10 Home edition cannot install Docker, it is necessary to do some unconventional means before normal installation, so as to ensure the successful installation of Docker. Docker Desktop can be installed by scripting hyper-V on the home edition.

 

1. Install

1. Open the Hyper – V

To add it, simply save the following as a.cmd file and open it as an administrator. When prompted to restart, save the file and restart. When you’re done, you can use hyper-V with full functionality.

pushd "%~dp0" dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt for /f %%i in ('findstr /i . hyper-v.txt  2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i" del hyper-v.txt Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALLCopy the code

 

2. Disguise yourself as a professional version to bypass installation detection

As shown in the figure, because Docker Desktop will detect the system version during installation, direct installation will show installation failure. So you need to change the registry to bypass installation detection.

You can run the following CMD command with administrator privileges (it is possible and more convenient to test this yourself) :

REG ADD "HKEY_LOCAL_MACHINE\software\Microsoft\Windows NT\CurrentVersion" /v EditionId /T REG_EXPAND_SZ /d Professional /F
Copy the code

Note: 1. Back up the registry before modifying it. 2. After the restart, the registry value will be automatically restored, but docker operation will not be affected.

3. The installation

Once these two pieces are ready, they can be installed normally. Download address: hub.docker.com/editions/co…

Before downloading, you need to register your login account and then select the corresponding version ->Docker Desktop for Windows

Download and click Install, follow the default options to install.

 

2. The test

After the installation is complete, the system will restart. Then you can open CMD and run:

docker verison
Copy the code

The output is as follows:

C:\Users\YSS> Docker version Client: Docker engine-community version: 18.09.2 API Version: 1.39 Go version: Git Commit: 6247962 Built: Sun Feb 10 04:12:31 2019 OS/Arch: Windows/AMD64 ExperimentalfalseServer: Docker Engine - Community Engine: Version: 18.09.2 API Version: 1.39 (minimum Version 1.12) Go Version: Built: Sun Feb 10 04:13:06 2019 OS/Arch: Linux/AMd64 Experimentalfalse
Copy the code

If the docker is installed successfully, let’s print a hello-world test

Run the following command to grab the image file from the repository to local.

docker pull library/hello-world
Copy the code

In the above code, docker image pull is the command to grab the image file. Library /hello-world is the location of the image file in the repository, where library is the group where the image file is located, and hello-world is the name of the image file.

After successfully fetching, you can see the image file on the machine.

Docker images # REPOSITORY TAG IMAGE ID CREATED SIZE Docker. IO /hello-world latest f2a91732366c 3 months ago 1.848 kBCopy the code

Now, run the image file.

Docker run hello-world # display result Hello from docker! This message shows that your installation appears to be working correctly. ...Copy the code

After this prompt, hello World stops running and the container terminates automatically. Some containers do not terminate automatically because they provide services, such as Mysql images, etc.

Common commands

In addition to the Docker command we used above, Docker also has some other commonly used commands

Pull the Docker image

docker pull image_name
Copy the code

Docker is stored in /var/lib/docker:

docker images
Copy the code

Remove the mirror

IO /tomcat:7.0.77-jre7 or docker RMI b39C68b7af30Copy the code

View which containers are currently running

docker ps
Copy the code

View all containers

docker ps -a
Copy the code

Start, stop, restart container commands:

docker start container_name/container_id
docker stop container_name/container_id
docker restart container_name/container_id
Copy the code

After starting a container in the background, you can use the attach command to access the container:

docker attach container_name/container_id
Copy the code

Delete container command:

docker rm container_name/container_id
Copy the code

View the current system Docker information

docker info
Copy the code

Download an image from a Docker Hub:

docker pull centos:latest
docker pull centos:latest
Copy the code

Executing docker pull centos will download all images from the centos repository to the local repository.

 

Reference:

1. blog.csdn.net/qq_34464926…

2. blog.51cto.com/ityouknow/2…