Install the latest version of docker, change the docker installation location, save the image data path, configure the image accelerator

Install the latest version of docker, change the docker installation location, save the image data path, and configure the image accelerator.

1. Download

According to your own platform and environment, select the corresponding version to download and deploy, here is the latest official address.

click to enter

2. Installation

There is nothing to pay attention to in this step. Double-click installation in windows system, and Linux/MacOS installation through double-click or command line is very simple.

The only thing to note is that Linux/MacOS update the relevant basic dependencies, update wsl2 before Windows system installation, and update it at the following address:

click to enter

Linux installation:

Linux distribution Ubuntu installation method
 switch to admin rights
$ su root
 Install necessary dependencies
$ apt-get update 
$ apt-get -y install apt-transport-https ca-certificates curl software-properties-common
 Install GPG Certificate
$ curl -fsSL | sudo apt-key add -
Write software source information (Alibaba cloud mirror source)
$ add-apt-repository "deb [arch=adm64] $(lsb_release -cs) stable"
update and install Docker-CE
$ apt-get -y update 
$ apt-get -y install docker-ce


Linux distribution CentOS Install
 switch to root permission
$ su root
 Install necessary dependencies
$ yum install -y yum-utils device-mapper-persistent-data lvm2
 Add software source information (Alibaba cloud mirror source)
$ yum-config-manager --add-repo
 update and install Docker-CE
$ yum makecache fast 
$ yum -y install docker-ce

3. Modify the installation location and data storage location

When docker is installed, the installation is completed directly by default, and there is no step to specify the installation location and image storage location. If you consider that your own system disk is not enough, you can migrate it to other empty disks for use.

There are two main ways to change the data location:

1. Point to other disk locations through a similar soft connection;
2. Through real data migration, and change the location of data distribution;

Here we take the Linux kernel subsystem under windows and based on WSL2 as an example. In fact, such well-known projects are relatively active. There are many issue s for open source projects that can provide reference. After all, there are many people and diverse environments, and various problems will be encountered. You can search for them for reference. The addresses are as follows:

Click to view

1. Change the data pointer (similar to soft connection)

stop docker ;

Will C:\Users\username\AppData\Local\Docker  Copy the contents of the directory to the storage location you need to set, for example: D:Docker\ ;

implement mklink /D C:\Users\username\AppData\Local\Docker D:Docker\ ;

Restart docker ;

2. Change through data migration (recommended)

First look at the relevant commands of WSL

wsl --help

all rights reserved (c) Microsoft Corporation. all rights reserved.

usage: wsl.exe [parameter] [Options...] [Command Line]

for running Linux Parameters for binary files:

    If no command line is provided, wsl.exe will start the default shell. 

    --exec, -e <Command Line>
        Execute the specified command without using the default Linux shell. 

        Pass the rest of the command line as is.

    --distribution, -d <distribution>
        Run the specified distribution.

    --user, -u <username>
        Run as the specified user.

for management Linux of Windows Subsystem parameters:

    --export <distribution> <file name>
        Export distribution to tar document.
        For standard output, the filename can be -. 

    --import <distribution> <Installation location> <file name> [Options]
        will be specified tar The file is imported as a new distribution.
        For standard input, the filename can be -. 

            --version <Version>
                Specifies the version to use for new distributions.

    --list, -l [Options]
        List distributions.

                List all distributions, including currently running
                Installed or uninstalled distributions.

                Only the currently running distributions are listed.

            --quiet, -q
                Only the distribution name is displayed.

            --verbose, -v
                Displays detailed information about all distributions.

    --set-default, -s <distribution>
        Set distribution as default.

    --set-default-version <Version>
        Change the default installed version for new distributions.

    --set-version <distribution> <Version>
        Change the version of the specified distribution.

        Immediately terminate all running distributions and WSL 2 Lightweight tool virtual machine.

    --terminate, -t <distribution>
        Terminates the specified distribution.

    --unregister <distribution>
        Log out of distribution.

        Display usage information.

This can be achieved with the following few lines of commands:

closure docker: 
Exit a running one via command or menu docker

Close all distributions:
wsl --shutdown

Check the version number first:
wsl --list -v

data export (if docker moved to D:Docker Under contents):
wsl --export docker-desktop D:\Docker\docker-desktop-back
wsl --export docker-desktop-data D:\Docker\docker-desktop-data-back

Log out of the installation:
wsl --unregister docker-desktop
wsl --unregister docker-desktop-data

wsl --import docker-desktop  D:\Docker\docker-desktop D:\Docker\docker-desktop-back --version 2
wsl --import docker-desktop-data  D:\Docker\docker-desktop-data D:\Docker\docker-desktop-data-back --version 2

reboot docker: 
Start the run by command or menu docker to use

File organization:
The related files in the original directory can be deleted to save disk space, and backups can also be kept.

Pay attention to the details, there are many similar shares on the Internet, but some export and import file paths or file suffixes have one more or one less. The commands here can basically be copied and pasted directly for use.

Fourth, configure the mirror accelerator

Here we mainly take Alibaba Cloud Mirror as an example, others are similar.

1. Open the Alibaba Cloud Image Library: Click to open

If you need to log in, you can log in directly with an account.

2. Select "Image Accelerator" in the lower left corner, and then select the OS running Docker according to the platform of your personal system, and modify the Docker configuration file according to the requirements of the operation document, and finally restart Docker to complete the accelerator configuration service.

3. For detailed docker configuration documents, please click to view: Click to view

For more interesting practical techniques, please check the corresponding column.

For more dry goods resources that can make you grow, please read more articles.

Leave a comment, like and follow, we will share the dry goods of AI learning and development together.

Your random tip may create the next Linus ~

Serious technology, bad programmers~

Tags: Linux Windows Docker

Posted by cainy1982 on Mon, 09 May 2022 13:02:52 +0300