How to configure the memory size for docker?

coldplay.xixi
Release: 2020-06-13 12:54:13
Original
8231 people have browsed it

How to configure the memory size for docker?

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
Copy after login

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/demoMount logs to the host

* -e TZ="Asia/Shanghai"Set time zone

* --privileged =trueSet up to have real root permissions in the container

* -p 8080:8080 Map port

* tomcat8Mirror 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

Recommended tutorial: "

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template