Docker simple and practical steps

First start the docker background process

systemctl start docker

service docker start

List the images on the machine

docker images

View docker process

docker ps

Start a container from image (run)

         The docker run command first creates a writable container from a specific image, and then starts it through the start command. The stopped container can be restarted and retain the original modification. There are many startup parameters for the run command. The following are some general instructions. For more details, please refer to http://www.cnphp6.com/archives/24899.
When using docker run to create a container, the standard operations of Docker running in the background include:

Check whether the specified mirror exists locally, and download it from the public repository if it does not exist.
Create and start a container using the mirror.
Assign a file system and mount a read-write layer outside the read-only mirror layer
. The network bridge configured from the host host The interface bridges a virtual interface to the container to
configure an ip address from the address pool to the container to
execute the user-specified application
and the container is terminated after execution

docker create --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.3.2
Create container es based on image file

container start

docker start container_name

View container log

docker logs container_id

View container_id

docker ps -a

View the value of max_map_count

cat /proc/sys/vm/max_map_count

 

Elasticsearch java minimum memory host machine: sysctl -w vm.max_map_count=262144

 

Test whether elasticserach is successful

curl -X GET localhost:9200/

 

Docker and container interactive execution of single or multiple commands

docker exec elasticsearch bash -c "cd /bin/;ls";
 

Enter the container and execute interactive shell i interactive t terminal 

docker exec -it  CONTAINER_ID  bash 

The interaction between attache and -it is different, attach displays the current log output information

ocker attach --sig-proxy=false $container_id

The startup of es in docker is slow, and the memory is 4G

Centos virtual machine cannot access the Internet, there may be no host route

route add 0.0.0.0 netmask 0.0.0.0 gw 192.168.  eth0

                               vg logical volume

lvcreate -L 0.9G vg_data4 -n LVdata4

Level of directory size

du -h --max-depth = 1
 

Clean up docker space

docker system prune

head plugin

Need to modify the es configuration file after docker pull

vi config/elasticsearch.yml 最下面加上两行
http.cors.enabled: true 
http.cors.allow-origin: "*"

报错:"error": "Content-Type header [application/x-www-form-urlencoded] is not supported",解决方法

-H 'Content-Type:application/json'

curl -H 'Content-Type:application/json' -XPOST http://localhost:9200/company/employee/1 -d '{"first_name" : "John","last_name" : "Smith","age" : 25,"about" : "I love to go rock climbing","interests": [ "sports", "music" ]}'
 

**Installation of word segmentation IK must be consistent with the version of es

 

If the docker container cannot start after modifying the file, the simple recovery method is to delete the container, and then recreate the container through image create

Insert data

curl -X PUT http://localhost:9200/index2/ Create index

curl -H'Content-Type:application/json' -XPOST http://localhost:9200/index2/_analyze -d'{"analyzer":"ik_max_word","text": ["Book copyright, short book copyright belongs to Author owned "]}'

query DSL 查询
curl -X GET localhost:9200/index2/_search '{   "query": { "match_all": {} },;   "_source": ["text"]; }'

 

1. User_id is of string type, but its index is defined as "not_analzyed". This needs to be understood: usually, the full-text search function in the search engine is simply implemented as follows: the original document is used after word segmentation These words are used to establish an inverted index. When searching online, the user's query words are segmented, and the word segmentation results are used to pull the zipper results of multiple inverted indexes, merge, and rank the relevance to obtain the final result. However, for some string type fields, I actually don’t want to create an inverted row, I just want to match exactly, such as the user’s name, I only want to find the person whose name field is exactly "Zhang San" instead of "Zhang" after word segmentation. Four" and "Li San" two people, this time, you need to define the index type field. There are three types of this field: no, analyzed, and not_analyzed. No means that this field is not indexed at all. Analyzed is built by analysis and full-text search, and not_analyzed is a query method that exactly matches keywords.

 

 

Guess you like

Origin blog.csdn.net/myidea999/article/details/93626713