Docker study notes 1: Install Docker for WSL in Windows and use Alibaba Cloud Container Image Service

Recently I was preparing to start a set of NAS, so I decided to study the famous Docker container first.

Install Docker into WSL

In the first step of the installation, I was pitted (I did not expect to install so many software...)

Because the Linux version I chose is Ubuntu 18.04, so I tried to install it directly with apt in Ubuntu, and found that the service could not get up at all. And the reason for the error is what system kernel needs to be upgraded, which scared me to apt remove...

Later, I found out that I only need to download the Windows version from the official website, and then directly select to open WSL in it. The result is more complicated.

First of all, explain a big pit, which only supports the window10 professional version system, or has installed docker for window10, otherwise the daemon cannot be started, even if no error is reported step by step to the end, docker cannot be started. I have always been lucky to think that I can find a solution for almighty netizens, or that I can try to get a solution, but later found that it can only be achieved unless the above conditions are met.

Let’s sort out the installation steps below

  1. Download the Windows version on the Docker official website
  2. Keep clicking next during the installation process
  3. After the installation is complete, you need to log off or restart the computer
  4. After the restart is complete, you will see a cute little dolphin in the lower right corner, right click setting> General to check all options
  5. Check Resources> WSL INTEGRATION to see if there is any Linux version you have installed, if not, please execute 6; if you already have the version you have installed, just click the check box and restart.
  6. If your Linux does not appear, open Powershell and execute wsl --set-default Ubuntu-18.04 2 , where Ubuntu-18.04 is the version of Linux you installed, you can use wsl -l -v to view

At this time, enter your wsl and try docker ps. If there is no error, it can be used.

You can also switch between windows docker and Linux docker when you right-click the icon in the lower right corner

Use Alibaba Cloud's image container service

Register an Alibaba Cloud service first

After registration is complete, set a login password in the instance list> default instance> access credentials, and then you can see a series of commands below. Before that, you need to execute a command in your WSL

sudo ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-credential-desktop.exe /usr/bin/docker-credential-desktop.exe

This sentence is to make docker-credential-desktop.exe executable in Linux

Then execute the command in Alibaba Cloud

sudo docker login --username=******** registry.cn-hangzhou.aliyuncs.com

This string of * represents your login name, you can modify it yourself

Enter the password you created yourself and you will be prompted to log in successfully

Create your private warehouse in Alibaba Cloud

Click on Container Mirror Service> Instance List> Mirror Warehouse, click Create Mirror Warehouse, and fill in the content in turn

Then click the management button on the right to view various commands

Log in to the Alibaba Cloud Docker Registry

$ sudo docker login --username=mrxun**** registry.cn-hangzhou.aliyuncs.com
The username used to log in is the full name of the Alibaba Cloud account, and the password is the password set when the service is activated .

You can modify the credential password on the access credential page.

Pull the image from the Registry
$ sudo docker pull registry.cn-hangzhou.aliyuncs.com/xxxx/xxxx:[镜像版本号]
Push the image to the Registry
$ sudo docker login --username=**** registry.cn-hangzhou.aliyuncs.com
$ sudo docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/xxxx/xxxx:[镜像版本号]
$ sudo docker push registry.cn-hangzhou.aliyuncs.com/docker_learning_test/my_first_docker:[镜像版本号]

Please replace the [ImageId] and [Image version number] parameters in the example according to the actual image information.

Choose a suitable mirror warehouse address

When pushing images from ECS, you can choose to use the intranet address of the image warehouse. The push speed will be improved and your public network traffic will not be lost.

If the machine you are using is on a VPC network, please use registry-vpc.cn-hangzhou.aliyuncs.com as the domain name of the Registry to log in.

Example

Use the "docker tag" command to rename the image and push it to the Registry through the private network address.

$ sudo docker images
REPOSITORY                                                         TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
registry.aliyuncs.com/acs/agent                                    0.7-dfb6816         37bb9c63c8b2        7 days ago          37.89 MB
$ sudo docker tag 37bb9c63c8b2 registry-vpc.cn-hangzhou.aliyuncs.com/acs/agent:0.7-dfb6816

Use the "docker push" command to push the image to the remote.

$ sudo docker push registry-vpc.cn-hangzhou.aliyuncs.com/acs/agent:0.7-dfb6816

The article was first published at https://www.mrxun.in/ Welcome to follow

Guess you like

Origin blog.csdn.net/qq_32115939/article/details/110481871