Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle and function of Docker in springboot

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the principle and function of Docker in springboot". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

5. Docker1. Brief introduction

Docker is an open source container engine

Docker supports compiling the software into an image, then configuring the various software in the image, and then publishing the image, so that other users can use the image directly.

A running image is called a container, and the container starts very quickly.

two。 Core concept

Docker host (Host): a machine with docker programs installed (docker installed directly on the operating system)

Docker client (Client): connect to the docker host for operation

Docker repository (Registry): used to hold various packaged software images

Docker image (Images): the image packaged by the software and placed in the docker repository

Docker container (Container): an instance after the image is started is called a container. A container is an application or a group of applications that run independently.

Steps for using docker:

Install Docker

Go to the Docker warehouse to find the image of the required software.

Run the image using Docker, and the image generates a Docker container

The start and stop of the container is the start and stop of this software.

3. Install Docker1. Install a virtual machine

Install VMWare, VirtualBox

Create a new virtual machine instance in the virtual machine (or import an existing virtual machine image)

Start the virtual machine and log in using the root user (root/zhangjiahui)

Use the client to connect to the linux server for command operations

Set up the network of the virtual machine

Bridging network-> Select the local network card (view the network card used by the host network connection)

Set the IP information and restart the network service

DEVICE= "ens33" TYPE= "Ethernet" DEFROUTE= "yes" ONBOOT= "yes" HAADDR= "00:0C:29:A3:C5:51" # configure IPADDR= "192.168.116.10" GATEWAY= "192.168.116.2" NM_CONTROLLED= "no" DNS1= "8.8.8.8" NETMASK= "255.255.255.0" according to the network card information corresponding to your virtual machine

Set the network to a fixed IP address (centos7-- > vi / etc/sysconfig/network-scripts/ifcfg-ens33)

Restart network services

Centos7 network card restart method 1, centos6 network card restart method: service network restart centos7 network card restart method: systemctl restart network 2, DNS configuration file: cat / etc/resolv.conf setting host and IP binding information: cat / etc/hosts setting host name: cat / etc/hostname 3, you can use nmtui text box to modify IP 4, Turn off the firewall and set the boot not to start to view the firewall status: systemctl status firewalld.service off: systemctl stop firewalld enabled: systemctl start firewalld boot auto off: systemctl disable firewalld boot auto off: systemctl enable firewalld check whether boot is started: chkconfig-- list | grep network (RHLE6) 5, Temporary and permanent shutdown Selinux temporary shutdown: _ getenforce Enforcing _ setenforce 0 setenforce:SELinux is disabled permanent shutdown: _ vim / etc/selinux/config

Connect to the linux virtual machine through ssh

two。 Install Docker on CentOS 7

Steps:

Check the kernel version (must be above 3.10)

# check linux kernel version uname-r

Install docker

# docker installation Command yum install docker# Intermediate prompt for yy

Start docker

# start dockersystemctl start docker# to check the docker version number docker-v

Set docker to boot

# docker boot setup command systemctl enable docker# command execution result prompt content Created symlink from / etc/systemd/system/multi-user.target.wants/docker.service to / usr/lib/systemd/system/docker.service.

Stop docker

# docker stop command systemctl stop docker4. Docker common operations and commands 1. Mirror operation # retrieve # # https://hub.docker.com#usage: docker search keyword docker search mysql# pull # usage: docker pull image name [: image tag] # without tag, default is latestdocker pull mysql:5.5# local image list view # usage: docker imagesdocker images# delete downloaded local image # usage: docker rmi image ID # # Image ID can view docker rmi f991c20cb5082 through the docker images command. Container operation

Software image-- > run image-- > generate container (that is, running software)

# search for image docker search tomcat# pull image docker pull tomcat# according to image Launch Container docker run-- name mytomcat-d tomcat:latest#-- name Custom Container name #-d background run # View running Container docker ps# stop running Container # # id View docker stop d41fcf7ec705 # Container IDdocker stop mytomcat # Container name# View all containers (including running and exited containers) docker ps-a # start containers that already exist and exit # # id can view docker start d41fcf7ec705 # Container IDdocker start mytomcat # Container name# Delete existing Container docker rm d41fcf7ec705 # at this time the container must have stopped docker rm-f d41fcf7ec705 # then the container can start a port-mapped tomcat container docker run-d-p 8888 IDdocker start mytomcat 8080 tomcat:latest#-p HOST_PORT:CONTAINER_PORT in running status # renaming Container docker run The host port is mapped to a port inside the container # the firewall of the host has been turned off View status service firewalld status# View Container run Log docker logs d41fcf7ec705docker logs mytomcat# more common commands 1. Https://docs.docker.com/ee/2. Refer to the user manual for each image on docker hub 5. Install common software image 1. Install and start mysql

Install & start command:

Docker run-- name mysql03-p 3306 MYSQL_ROOT_PASSWORD=zhangjiahui-d mysql:latest

Repair of remote client connection problems:

The mysql launched by connecting Docker appears: ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loadedC:\ mysqldata > mysql-h 127.0.0.1-P 13306-uroot-pEnter password: * ERROR 2059 (HY000): Authentication plugin' caching_sha2_password' cannot be loaded: solution: 1. Enter the mysql container docker exec-it mysql2 / bin/bash2. Enter mysqlmysql-uroot-pzhangjiahui3. Modify ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY' root';4 by default encryption method. Modify root password alter user 'root'@'%' identified by' zhangjiahui';flush privileges

Several advanced operations

1. Docker run-- name some-mysql-v / my/custom:/etc/mysql/conf.d-e MYSQL_ROOT_PASSWORD=my-secret-pw-d mysql:tag-v: Mount the / my/custom folder of the host to the / etc/mysql/conf.d folder To modify the configuration, you only need to modify the configuration file under / my/custom. Docker run-- name some-mysql-e MYSQL_ROOT_PASSWORD=my-secret-pw-d mysql:tag-- character-set-server=utf8mb4-- collation-server=utf8mb4_unicode_ci "what is the principle and function of Docker in springboot" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report