Docker actual deployment

Time:2021-10-17

Docker deployment nginx

#1. Search image searchit is recommended to search from docker to see the help documents
$ docker search nginx

#2. Download Image
$ docker pull nginx

#3. Start the nginx container, - d run in the background, - name name the container, - P access the default port 80 of nginx through port 3344 of the host
$ docker run -d --name nginx01 -p 3344:80 nginx

#4. Start successfully when viewing
$ docker ps

#5. Operation test

#6. Enter nginx container
$ docker exec -it nginx01 /bin/bash

#7. Stop nginx container
# exit
$docker stop nginx01 or container ID

Docker actual deployment

Concept of port exposure
Docker actual deployment

Question:
Every time you modify a file, you need to enter the container. It’s very troublesome. How can you provide a mapping path in the external container so that the file name can be modified automatically in the container when it is modified in the host computer?
-V data volume!

Docker deployment Tomcat

#Official use
docker run -it --rm tomcat:9.0

#We started in the background before. After stopping the container, the container can still find docker run - it -- RM, which is generally used for testing, running out and deleting

#Download and restart
docker pull tomcat:9.0

#Start
docker run -d -p 3355:8080 --name tomcat01 tomcat

#There is no problem with the test access

#Enter container
docker exec -it tomcat01 /bin/bash

#Problems found: 1. There are few linux commands, 2. There are no webapps. Alibaba images are the smallest images by default, so unnecessary images are eliminated
#Guaranteed minimum operational environment

#Display the page and copy the file under webapps.dist to the webapps directory
cp -r webapps.dist/* webapps

Docker deployment es (elastic search) + kibana

#Es exposes many ports
#Es consumes a lot of memory
#Es data generally needs to be placed in the security directory! mount 
#-- net somenetwork network configuration
$ docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:tag

#Download start
$ docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2

#When you start Linux, it gets stuck
$docker stats view CPU status

#Modify profile -e environment configuration
$ docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms64m -Xmx512m" elasticsearch:7.6.2

Connect es using kibana

Docker actual deployment

  • problem

How to use kibana to connect es and how to connect the network.

This work adoptsCC agreement, reprint must indicate the author and the link to this article