How to configure the memory size for docker?
How to solve the problem of docker configuration memory size:
1. Mount the configuration file in docker
By mounting the catalina.sh configuration file of tomcat in docker to the host machine, and then using catalina.sh to configure the jvm memory size.
1. You need to re-run a tomcat container (note: the port and container name cannot be repeated)
docker run -d \ -v /server/webapps:/usr/local/tomcat/webapps/ \ -v /server/catalina.sh:/usr/local/tomcat/bin/catalina.sh \ -v /server/logs/demo:/server/logs/demo \ -e TZ="Asia/Shanghai" \ --privileged=true \ --name demo \ -p 8080:8080 \ tomcat8
Instructions:
* -v /server /webapps:/usr/local/tomcat/webapps/
Mount the running directory of the current project to webapps under tomcat
* -v /server/catalina.sh:/usr/local /tomcat/bin/catalina.sh
Mount catalina.sh of the host machine to catalina.sh under tomcat in docker
* -v /server/logs/demo:/server/ logs/demo
Mount logs to the host
* -e TZ="Asia/Shanghai"
Set time zone
* --privileged =true
Set up to have real root permissions in the container
* -p 8080:8080
Map port
* tomcat8
Mirror Name
2.catalina.sh In the configuration memory
cygwin=false, add the following:
JAVA_OPTS="-server -Xms1024m -Xmx2048m -XX:MaxNewSize =256m -XX:PermSize=128m -XX:MaxPermSize=256m"
-xms initialization heap memory
-xmx maximum heap memory
二,Directly modify the configuration of catalina.sh of the tomcat container
You can directly enter the container to modify the configuration file of catalina.sh of tomcat, but this method is not recommended. Because it is troublesome to show the hang again in the future, and it is inconvenient to configure. If you need to re-run the container, you do not know the configuration of the memory size in the container
1. Enter the container
docker exec -it <container_name> /bin/bash
2. Find the catalina.sh configuration file and add the configuration (the configuration statement added in the first step is enough)
// If there is no vi command, you need to install
vi /usr/local/tomcat/bin/catalina.sh
// Exit the container and Restart
exit
##docker restart
docker video tutorial》
The above is the detailed content of How to configure the memory size for docker?. For more information, please follow other related articles on the PHP Chinese website!