1. Create virtual machine
-
Installing Oracle VM visualbox
-
Install vagrant
-
Install mirror CS/7
vagrant init centos/7 //Pull image vargant up // download
be careful:
Vagrant broke undefined conversionerror
reference resources
Original link: https://blog.csdn.net/weixin_44655599/article/details/112913219
2. Control it under command
Interrupt with CTRL + C
Log in using the vagrant ssh user
You can then use LINUX related commands
vagrant whoami // Current user ls/ // Current root directory exit // sign out up // start-up
You must determine that a. vagrantFile exists
Pay attention to software conflicts
Starscream 360 net master needs attention
3. Bind host to map port
First, find the network card configuration of the virtual machine Virtual BOX through the command line console ipconfig
The ip address for IPv4 was found
Locate the hp/vagrantFile for vagrant
Found after opening the file
config.vm.network "private_network", ip: "192.168.1.179
Replace the ip with the ip of the Virtual BOX
Restart the virtual machine vagrant reload after modification
WLAN is the module of windox
4. Install Docker into the virtual machine
What is Docker?
Virtualization container technology. Docker is based on image and can start various containers at the second level. Each container is a complete operating environment, and containers are isolated from each other.
[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-2ctcu0at-1634015053459) (C: \ users \ HP \ appdata \ roaming \ typora \ typora user images \ image-20211010182628657. PNG)]
First step
Uninstall the previous installation first
sudo
As a super administrator
sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
Step 2 set the storage warehouse
Set up repository
Install the yum utils package (provides the yum config manager utility) and set up a stable repository.
sudo yum install -y yum-utils sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
Step 3 install Docker engine
Install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
$ sudo yum install docker-ce docker-ce-cli containerd.io
Step 4 start Docker
sudo systemctl start docker
Step 5
Verify that the Docker Engine is installed correctly by running the Hello world image.
$ sudo docker run hello-world
Step 6: set startup and self startup
Start docker automatically under Linux
sudo systemctl enable docker
Step 7 configure image acceleration
First, open alicloud
Enter your own console
Then open the container image service under the first directory
Then, the directory 3 image tool - image accelerator
You can use the accelerator by modifying the daemon configuration file / etc/docker/daemon.json
-
First create a directory mkdir
-
Secondly, configure the image address
-
Restart the docker background thread
-
Restart the docker service
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://leppzjul.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
Step 8 Download MySQL redis
sudo docker pull mysql:5.7 sudo docker pull redis
Use sudo docker images to check the image
Create the relevant instance and match the port number
docker run -p 3306:3306 --name mysql \ -v /mydata/mysql/log:/var/log/mysql \ -v /mydata/mysql/data:/var/lib/mysql \ -v /mydata/mysql/conf:/etc/mysql \ -e MYSQL_ROOT_PASSWORD=root \ -d mysql:5.7
Using docker ps running commands
understand:
docker container file mount and port mapping
[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-aoyhrcwf-1634015053464) (C: \ users \ HP \ appdata \ roaming \ typora \ user images \ image-20211010194145635. PNG)]
Each docker run is to start a new container to isolate each other
first mysql adopt docker Isolate and put into a complete container mysql: /usr/bin/mysql /usr/lib/mysql /etc/mysql /usr/share/mysql then etc Is the relevant configuration file under the configuration file log Is under the configured log file docker run -p 3306:3306 --name mysql \ take linux3306 Port number mapped to windox 3306 port number under -v /mydata/mysql/log:/var/log/mysql \ It can be understood as a shortcut -v It is also called directory mount. This is the same file directory. You can see the relevant information externally - Hang on etc log as well as lib mysql data -v /mydata/mysql/data:/var/lib/mysql \ -v /mydata/mysql/conf:/etc/mysql \ -e Is to change file parameters -e MYSQL_ROOT_PASSWORD=root \ -d mysql:5.7
We can verify it
Enter the mysql container
-it interaction mode
docker exec -it mysql /bin/bash
It is equivalent to entering the mysql console
There will be on the left of the execution result root@xxxx address
[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-klpplqem-1634015053467) (C: \ users \ HP \ appdata \ roaming \ typora \ typora user images \ image-20211010194036733. PNG)]
You can use ls / the entire directory structure
[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-1kophhkyx-1634015053471) (C: \ users \ HP \ appdata \ roaming \ typora \ user images \ image-20211010194325133. PNG)]
You can use whereis mysql to verify
Enter the mysql conf folder and configure the internal code of mysql according to the format
[client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake skip-name-resolve
View the docker directory
$ docker inspect container_name | grep Mounts -A 20
lation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
see docker Change in directory
$ docker inspect container_name | grep Mounts -A 20