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

DOCKER application

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Https://yq.aliyun.com/articles/40494?spm=a2c4e.11153940.0.0.2e933068PIF5zP

Https://yq.aliyun.com/articles/2914?spm=a2c4e.11153940.0.0.722a1571t6wJyy

(install docker on windows) https://yq.aliyun.com/articles/698007?spm=a2c4e.11153940.0.0.2e933068PIF5zP

1. How does docker back up data and prevent data loss caused by container crash?

The characteristics of Docker determine that the container itself is non-persistent, and the data in the container is also deleted after the container is deleted. Docker provides data volumes (Volume) for persistent storage by mounting directories on the host.

However, in a clustered environment, the data volumes on the host have great limitations.

When containers are migrated between machines, data cannot be migrated and data volumes cannot be shared between different machines.

To solve these problems, Ali Cloud CCS provides third-party data volumes to package various cloud storage into data volumes, which can be mounted directly on the container and automatically remounted when the container is restarted or migrated. Currently, both ossfs and cloud storage are supported.

Two database applications use the data volumes on the host to meet the requirements.

2. Application of Dockers with different kernels

Now Docker can only run on machines with the Linux kernel.

So on Windows or Mac systems, you need to use Docker services through a virtual machine running Linux.

Docker Toolbox provides a complete set of tools that allow you to build this environment faster on Windows or Mac systems.

Docker Toolbox components include:

Docker ClientDocker MachineDocker Compose (Mac only) Docker KitematicVirtualBox

Docker Toolbox is suitable for Mac OS X 10.10.3 + or Windows 7 & 8.1.

There are two options for installing docker in Windows:

1 、 docker for windows

2 、 docker toolbox

Difference:

Docker for windows-64 bit Windows 10, Hyper-V must be enabled

Docker toolbox-just have virtualbox

2.1 DockerToolbox-18.03.0-ce.exe (http://mirrors.aliyun.com/docker-toolbox/windows/docker-toolbox/?spm=a2c4e.11153940.0.0.2e933068PIF5zP)

* Kitematic, which is a tool for GUI to manage Docker

A) download the latest v19.03.5 version of boot2docker.iso through Xunlei, put it in the system disk user directory\ .docker\ machine\ cache, click the Docker Quickstart Terminal icon to start the Docker Toolbox terminal, and create a virtual machine called default in the Virtualbox after running. There is a Start interactive shell prompt: use the docker command directly, or you can manage the virtual machine with PowerShell:

Status of the docker-machine ls / / Docker virtual machine

Docker-machine create-- driver=virtualbox default / / create a Docker virtual machine

Docker-machine env default / / get the environment variables of the virtual machine

Docker-machine env default | Invoke-Expression / / connect the current PowerShell to the Docker Linux in the virtual machine, and then you can use the docker command in PowerShell.

Https://developer.aliyun.com/mirror/docker-toolbox?spm=a2c6h.13651102.0.0.35dd1b11nt3EwC

B) Image acceleration win7

Https://yq.aliyun.com/articles/65076?spm=a2c4e.11153940.0.0.2e933068PIF5zP

You need to set a Registry login password independent of the account password to facilitate upload and download of images. (https://cr.console.aliyun.com/cn-hangzhou/new)

For users who have installed Docker Toolbox, refer to the following configuration steps:

Create a Linux virtual machine with a Docker environment installed, specify the machine name as default, and configure the Docker accelerator address. Go to PowerShell and execute it in turn

Docker-machine ssh default sudo sed-I "s | EXTRA_ARGS=' | EXTRA_ARGS='--registry-mirror= acceleration address | g" / var/lib/boot2docker/profile exit docker-machine restart default

After restarting Docker, you can use domestic images to speed up the download.

C) Image Accelerator CentOS7

Https://yq.aliyun.com/articles/29941?spm=a2c4e.11153940.0.0.393b2a65Q4AbyL

For the configuration of CentOS7, you need to copy the default configuration file first.

/ lib/systemd/system/docker.service-> / etc/systemd/system/docker.service

Then add the accelerator address to the startup command of the configuration file

Just restart Docker.

Sudo cp-n / lib/systemd/system/docker.service / etc/systemd/system/docker.servicesudo sed-I "s | ExecStart=/usr/bin/docker daemon | ExecStart=/usr/bin/docker daemon--registry-mirror= | g" / etc/systemd/system/docker.servicesudo sed-I "s | ExecStart=/usr/bin/dockerd | ExecStart=/usr/bin/dockerd-- registry-mirror= | g" / etc/systemd/system/docker.servicesudo systemctl daemon-reloadsudo service docker restart

3. Win7-- virtualbox-- boot2docker--mysql container network carding

A) mysql (docker container): / / mysql IP:PORT: 172.17.0.2 mysql IP:PORT 3306, Server version: 8.0.19 MySQL Community Server

PowerShell enters the container > docker exec-it c9bb34c9995b bash

# mysqladmin-uroot-pabc

# mysql- uroot-pabc / / enter mysql--ok

Question 1) mysql > GRANT ALL ON *. * TO 'sa'@'%' IDENTIFIED BY' abc'; / / does not support IDENTIFIED BY

Mysql > GRANT ALL ON *. * TO 'root'@'%'; / / ok

Question 2) the SQLyog connection reported an error "Authentication plugin 'caching_sha2_password' cannot be loaded" because the encryption rule in the previous version of mysql8 was mysql_native_password, followed by caching_sha2_password

Mysql > ALTER USER 'root'@'%' identified with mysql_native_password by' abc' / / restore mysql login password encryption rules to mysql_native_password, SQLyog connection OK.

Question 3) (unverified) use SQL Manager Lite for MySQL to import the backup database atcdb.back of the second institute, and report an error (the export dump also reports an error):

Error: ERROR 2026 (HY000): SSL connection error: unknown error number

Mysql > SHOW VARIABLES LIKE'% ssl%'; / / View the value of have_ssl is YES, indicating that SSL is enabled

Modify the configuration file my.cnf, add the content: skip_ssl, and then service mysqld restart takes effect. The value of have_ssl is DISABLED, indicating that SSL has been closed.

Import two databases): using SQLyog, execute the import OK by SQL statement. Atcdb.back is a sql batch file.

B) boot2docker: Linux default 4.14.154-boot2docker x861464

Docker0:172.17.0.1

Eth0:10.0.2.15

Eth2:192.168.99.100 / / netstat-an | grep 3306 / / View the usage of all 3306 ports: OK

Vethb40b498: no IPv4 address

C) virtualbox: network card 1:NAT

Network card 2:VirtualBox Host-Only Network # 2

Ssh manages the virtual machine boot2docker:docker-machine ip to get IP, or check out C:\ Users\ mizy\ .docker\ machine\ machines\ default\ config.json

D) win7:VirtualBox Host-Only Network:192.168.56.1

VirtualBox Host-Only Network # 2 OK 192.168.99.1 / / ping 192.168.99.100 (OK); netstat-an | findstr 3306 (No)

Wireless network connection: DHCP

Docker run-d-p 192.168.99.1 MYSQL_ROOT_PASSWORD='abc' mysql:latest 3306-- name mysql-e MYSQL_ROOT_PASSWORD='abc' mysql:latest / / cannot assign requested IP address

Docker run-d-p 192.168.99.100 MYSQL_ROOT_PASSWORD='abc' mysql:latest 3306-- name mysql-e MYSQL_ROOT_PASSWORD='abc' mysql:latest / / run OK

Docker rm $(docker ps-a-Q) / / remove deletes all containers

Docker run-d-- name nginx--volume nginx-vol:/usr/share/nginx/html-p 80:80 nginx:latest / / nginx/html is persisted in the / var/lib/docker/volumes/ nginx-vol/_data/ directory of the boot2docker virtual machine. If the _ data directory is empty, the container copies the contents. If it is not empty, the container does not copy. Automatically refresh the web page index.htm: add to achieve real-time update of broadcast numbers.

4. The MySQL container uses vi to "test OK"

The MySQL container does not have vi,yum, but it does have apt-get.

A) change the apt source, cat / etc/os-release, and check the version Debian GNU/Linux 10, Baidu Debian 10 apt domestic source:

Echo 'deb http://mirrors.163.com/debian/ buster main non-free contribdeb http://mirrors.163.com/debian/ buster-updates main non-free contrib# deb http://mirrors.163.com/debian/ buster-backports main non-free contribdeb-src http://mirrors.163.com/debian/ buster main non-free contrib# deb-src http://mirrors.163.com/debian/ buster-updates main non-free contribdeb-src http://mirrors.163.com/debian / buster-backports main non-free contribdeb http://mirrors.163.com/debian-security/ buster/updates main non-free contribdeb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib' > / etc/apt/sources.list

B) apt-get update / / refresh the cache list

C) apt-get install vim-y / / install vim

5. The name of the database in CentOS6 is mysql-server

Create a Docker image: docker commit rongqi-id phpwing:v1

Modify container time zone and restart takes effect: UTC-- > CST

Cp / usr/share/zoneinfo/Asia/Shanghai / etc/localtime

6. Dockerfile supports the initial commands of custom containers. Dockerfile cannot have interactive commands.

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

Database

Wechat

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

12
Report