Virtual machine download and install, Docker download and install

virtual machine

Virtual machine preparation

First check the virtualization status of your own computer.

Take win10 as an example, open the task manager:

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-hAcTh8aj-1668237822408)(day17/image-20220908175438522.png)]

If virtualization is disabled, you need to surf the Internet by yourself. How to enable virtualization on your own computer? Generally, you enter the BIOS to debug when starting up. Each brand or motherboard has different ways to enable it. You need to check it yourself.

RockyLinux has a 600M image compression package, and has sent a network disk connection:

Link: https://pan.baidu.com/s/1bCePepgJJ-8s9n7sJn_QDg?pwd=egno
Extraction code: egno

VirtualBox Tsinghua University version download path:

https://mirrors.tuna.tsinghua.edu.cn/virtualbox/

Students who fail to install can try to download versions above 5.2.38

The VirtualBox installation process is normal, and all kinds of next steps can be

Basic use of virtual machines

Install the virtual machine:

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-AFWLhY3y-1668238037999)(day17/image-20220909104530541.png)]
[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-uBuKFQk5-1668238038001)(day17/image-20220909104539798.png)]

Just install it directly.

Just make sure that the installation path has no Chinese and no spaces

Win11 cannot be installed on VirtualBox to download VMware, and then you need to search and download a CentOS 7.5 or above or RockyLinux image. Mac system students only need to master Homebrew.

what is a virtual machine

The so-called virtual machine is to open another virtual system in the current computer system. For this virtual system, we need to install the Linux system, and the java projects we develop will eventually run on the Linux system. It is normal to use windows for development.

what is linux

Linux is also a computer operating system. Compared with the Windows system, the Linux system pays more attention to system permissions, security and performance. However, the ease of use of Windows is good, and the ease of use of Linux is poor, because in the native state of Linux system, there is basically no software, and the ease of use is poor. Because Linux is open source, many individuals or organizations have enhanced the native Linux, and then released various enhanced versions of Linux.

There are more common enhanced versions of Linux on the market now:

CentOS、Ubantu、RockyLinux、RedHat…etc

Virtual machine network configuration

To configure a network share connection:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-6Bxo36CF-1668238038003)(1657528311357.png)]

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-2acUDXby-1668238038005)(1657528347065.png)]

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-IywwUcoo-1668238038007)(image-20220507174433989.png)]

If the drop-down box appears in the share, be sure to select the network card option of Virtualbox

Shared mirror resources for everyone, more than 600 M of resources, pure version of LockyLinux (for Virtualbox only), more than 3.5 G of resources, VMware version includes mirror images of all software, more than 4.1 G resources, and Virtualbox version includes mirror images of all software.

Virtualbox loads the virtual machine image

Unzip RockyLinux_8.5_VBM.7z (more than 600 M), get a 1.78GB folder, and open this folder.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-UGsbCxer-1668238038015)(1657529174891.png)]

Double-click the blue icon to automatically start the virtualbox virtual machine and load the current image.

It must be ensured that all paths where the current image file is located are not in Chinese

It is recommended to use the right-click -> administrator mode to run when starting Virtualbox. If there is a problem with virtualbox startup that cannot be solved, you can refer to the following article to install VMware

Link: Install VMware

Configure mirroring parameters

Select the image, click Settings, and modify the usb settings;

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-glBtrmMI-1668238038019)(image-20220509093858825.png)]

Modify the network settings. The name of the network card 2 is the Ethernet shared by the network just now. If the error of name or service not known occurs when trying to connect to the network below, it means that the interface name of the network card 2 is wrongly selected. Go back to the settings and select again;
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-MfzY5Alf-1668238038021)(image-20220509094419625.png)]
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-Wi1Hq078-1668238038023)(image-20220509094434083.png)]

The bridged network card must be a network card with a network connection.

Start the virtual machine

After the above configuration is completed, you can start the virtual machine. After starting the virtual machine, wait for the login page to appear. After booting, the first item will be automatically selected without modification. If the mouse is captured by the virtual machine after booting, use the right Ctrl key to release it.

The username and password are both rockylinux by default.

There is no prompt when entering the password, but it can be recognized normally

After logging in, our user is the rockylinux user, and we try to connect to the network

ping www.baidu.com

If there is a periodic response, it proves that the network is smooth and the virtual machine can use the network functions of the current computer. Ctrl+C can exit the currently running program at any time and return to the command prompt. If there is no response, try to readjust the network sharing configuration of the network card and the network card bridging configuration of the virtual machine.

switch to root user

So far, we have successfully logged in to the Linux system. At the same time, the user who is operating is rockylinux. This user does not have all the permissions of the system, and all subsequent content may be blocked due to insufficient permissions.

Need to switch to root system administrator privileges;

enter

sudo su -

You can switch to the root user, and then set a password for the root user, and only with the password can you log in to the root user;

passwd

You can enter the process of setting the password. It is recommended not to use numbers as the password. It is recommended to use root as the password during the learning process. The current virtual machine is also a computer in the network. If we want to access it, we must have an available ip address;

ifconfig

or

ifconfig | more 

Display information line by line. Through the above command, you can see the ip address of your own virtual machine. This ip address may be

192.168.56.101

Remember this IP, and use this IP to access it later.

Client software connects to Linux

Download the Bitvise SSH Client software, install all kinds of next steps, and the following icon will appear on the desktop after installation.

[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-xlFSDkLg-1668238038025)(day17/image-20220509104332083.png)]

This software is a client that remotely connects to linux. Double-click this icon to enter the virtual machine connection interface. Host is the IP address of the virtual machine just now, Port is fixed at 22, Username is root, Initial method is changed to password to log in, select Store encrypted password in profile, enter the password, and click login in.

If an error is reported, change the ip address. Usually there will be several ips to try one by one. If a pop-up window appears indicating that the connection is successful, click the option on the left below the pop-up window.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-jrlpAbus-1668238038026)(day17/image-20220508150324092.png)]

After we use this software to connect successfully, we can use the interface provided by this software to operate Linux. Whether it is a virtual machine or an actual physical server, if we want to remotely control this machine, we need to use a special client to connect to the server and send instructions to the server. This software can complete this function.

Docker overview

What is Docker

We are going to learn how to install and use Docker to configure software in Linux (RockyLinux).

Docker is an open platform for developing, shipping and running applications. Use Docker to decouple applications from infrastructure so that software can be delivered quickly. With Docker, you can manage your infrastructure the way you manage your applications. By taking advantage of Docker's approach to quickly shipping, testing, and deploying code, you can significantly reduce the latency between writing your code and running it in production.

Why use Docker

  • Faster application delivery and deployment:

After the traditional application development is completed, a bunch of installation programs and configuration documentation need to be provided. After installation and deployment, complex configurations must be performed according to the configuration documentation to run normally. After Dockerization, only a small number of container image files need to be delivered, and the image can be loaded and run in the official production environment. The application installation configuration is already built into the image, which greatly saves the time for deployment configuration and test verification.

  • More convenient upgrade and expansion and contraction:

With the development of microservice architecture and Docker, a large number of applications will be structured through microservices. The development and construction of applications will become like Lego building blocks. Each Docker container will become a "building block", and application upgrades will become very easy. When the existing container is not enough to support business processing, the new container can be quickly expanded by mirroring, so that the expansion of the application system can be changed from the original day level to the minute level or even the second level.

  • Easier system operation and maintenance:

After the application is containerized, the application running in the production environment can be highly consistent with the application in the development and test environment. The container will completely encapsulate the environment and state related to the application, and will not affect the application due to the inconsistency of the underlying infrastructure and operating system, resulting in new BUG. When a program exception occurs, it can also be quickly located and repaired through the same container of the test environment.

  • More efficient use of computing resources:

Docker is kernel-level virtualization, which does not require additional Hypervisor [management program] support like traditional virtualization technology, so many container instances can run on a physical machine, which can greatly improve the CPU and memory utilization of the physical server.

Docker running architecture diagram

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-4tHFb1Yu-1668238038029)(day17/image-20220509113508212.png)]

Docker related information

Docker official website: http://www.docker.com

Docker Hub official website (mirror warehouse): https://hub.docker.com

All steps refer to the official documentation: https://docs.docker.com/engine/install/centos/

Install Docker

Three installation methods provided by the official website:

  • Set up the docker repository and install the required content from the repository.
  • Download the RPM installation package and manually update the installation.
  • Install using custom scripts for test and development environments.

The first of the three methods is relatively simple to install from the docker warehouse. This method requires the current virtual machine to have a network environment. Make sure that the network environment is available and then run the following command.

RockyLinux supports installing various programs using the yum command,

The yum command installer is similar to the application store in the mobile phone

Install the yum-utils package first to make it easier to install programs provided in the "App Store".

yum install -y yum-utils

Specify the docker warehouse path:

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

Ali warehouse path:

http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

To install Docker, also use the yum command.

yum -y install docker-ce docker-ce-cli containerd.io

It will take some time to download and install. If the download is slow, configure the address of the Ali Docker warehouse above. After the operation is completed, Docker will be installed in the current Linux system. We need to enter the command to start Docker to make Docker work.

systemctl start docker

test-docker

In order to ensure that our Docker is running normally, Docker provides a mirror that specifically tests Docker functions.

docker run hello-world

It may take a short time to run, and the following content appears in the running result, indicating that everything is normal.

Hello from Docker!

This message shows that your installation appears to be working correctly.

docker noun explanation

  • container

First of all, you need to understand what a container is. A container is a process, and inside it is an application or a group of applications that run independently. It can be started, started, stopped, deleted. Each container is isolated from each other to ensure a secure platform.

  • mirror image

Image is a read-only template file. Images can be used to create Docker containers, and one image can create many containers. Just like classes and objects in Java, classes are mirror images, and objects are containers! The mirror image can also be regarded as a mold, and the container created by the mirror image is the actual product created one by one through this mold.

  • host

The host machine is the server (linux) where we call the command to create the container using the image.

  • Mirror warehouse (repository)

A warehouse used to accommodate multiple images, you can link the warehouse to obtain the internal image you want. Generally, a mirror warehouse contains multiple images with different tags.

  • mirror server (registry)

The server occupied by the mirror warehouse. Note here that a mirror server does not necessarily have only one warehouse. There can be many warehouses, and each warehouse keeps different images.

  • client (docker-client)

Call the docker command to operate the image and the process of the container. As long as the host can be connected, the process of operating docker is docker-client.

Docker basic commands

Docker command format

Syntax Structure of Docker Commands

docker 子命令 [选项]

What are the subcommands of docker? We can use the helper subcommand of docker to view

docker --help

If you want to query how to use specific subcommands:

docker 子命令 --help

One of our most commonly used subcommands: help on run that starts a docker container can be

docker run --help

Of course, you can also query official documents or Baidu to learn more

https://docs.docker.com/reference/

images command

The docker images command can mainly complete the function of viewing the current local mirror warehouse

docker images

The return result of this command shows:

  • REPOSITORY: The name of the mirror warehouse, also known as the mirror name.
  • TAG: label, commonly used version number to identify the warehouse, if it is latest, it is the latest version.
  • IMAGE ID: image id.
  • CREATED: Create mirror time.
  • SIZE: size.

Common options for the docker images command are as follows

  • -a: display all information
  • -q: Only display the mirror id, which is more commonly used when there are many mirrors

search command

Before pulling the mirror, we need to specify the correct mirror name. We can enter query keywords to search the mirror warehouse.

The search command can search the content in the remote mirror server bound to the current system.

docker search mysql

The return result of this command shows:

  • NAME: Image name.
  • DESCRIPTION: Image description.
  • STARS: Mirror star rating, the higher the temperature, the more users.
  • OFFICIAL: Whether it is an official image.
  • AUTOMATED: Whether to support automatic deployment.

pull command

According to the results of our search above, after confirming the keywords, we can use the pull command to pull the software we queried to the local warehouse.

docker pull [镜像名称]
docker pull mysql

The latest version is downloaded by default. If you want to specify the version number, you can specify it after the name.

docker pull mysql:5.7.35

As for the version number to be specified, you can check it on the relevant official website.

Guess you like

Origin blog.csdn.net/weixin_43121885/article/details/127820857