Prepare the Cestos image, tomcat, and JDK
Cestos is docker pull.
Create docker: mkdir-P/opt/docker under/opt/
Decompress Tomcat and JDK to the docker directory and name them Tomcat and JDK respectively.
Delete unnecessary files in the JDK folder to reduce the size of the build image.
rm -rf /z/docker/jdk/*src.zip /z/docker/jdk/lib/missioncontrol /z/docker/jdk/lib/visualvm /z/docker/jdk/lib/*javafx* /z/docker/jdk/jre/lib/plugin.jar /z/docker/jdk/jre/lib/ext/jfxrt.jar /z/docker/jdk/jre/bin/javaws /z/docker/jdk/jre/lib/javaws.jar /z/docker/jdk/jre/lib/desktop /z/docker/jdk/jre/plugin /z/docker/jdk/jre/lib/deploy* /z/docker/jdk/jre/lib/*javafx* /z/docker/jdk/jre/lib/*jfx* /z/docker/jdk/jre/lib/amd64/libdecora_sse.so /z/docker/jdk/jre/lib/amd64/libprism_*.so /z/docker/jdk/jre/lib/amd64/libfxplugins.so /z/docker/jdk/jre/lib/amd64/libglass.so /z/docker/jdk/jre/lib/amd64/libgstreamer-lite.so /z/docker/jdk/jre/lib/amd64/libjavafx*.so /z/docker/jdk/jre/lib/amd64/libjfx*.so
Create a dockerfile
# Use the docker Cestos image from docker. IO/centos # author information maintainer guuyoog <Gy> label description = "this image is used to serve Tomcat 8 whit jdk8" version = "1.0" # create a directory in the image # Set JDK and tomcat to run mkdir-P/opt/jdk1.8.0 _ 181add JDK/opt/jdk1.8.0 _ 181run mkdir-P/opt/tomcat-8.5.32ADD tomcat/opt/tomcat-8.5.32 # Add Environment Variables env java_home/opt/jdk1.8.0 _ 181env catalina_home/opt/tomcat-8.5.32ENV path $ path: $ java_home/bin: $ catalina_home/binenv java_opts "$ java_opts-server-XX: + useparalleloldgc-XX: + heapdumponoutofmemoryerror-XX: heapdumppath =/opt/tomcat-8.5.32/dump. hprof-XX: + printgcdetails-XX: + printgctimestamps-xloggc:/opt/tomcat-8.5.32/dump/heap_trace.txt-duser. timezone = GMT + 08 "# work zone workdir/opt/tomcat-8.5.32 # expose port expose 8080 # Run tomcatcmd [" Catalina. sh "," Run "]
Start building docker image files
Docker build-T guuyoog/centos-jdk8-tomcat8: 1.0.-t set the tag name, naming rule registry/image: tag. Indicates using the dockerfile file under the current directory
If no problem exists, docker images can check the newly created image.
Export image docker save-O jdk8-tomcat8.tar <image ID>
Import image docker load <jdk8-tomcat8.tar
Docker images may not see the repository and tag, then use docker tag 639d56a4231a taomeng/jdk8-tomcat8: 1.0 assignment
Create a container
Sudo docker run-it -- name Tomcat -- Net = Host-P 8080: 8080-M 1024 m \ # set the maximum container memory usage; -- restart = always \ # restart Mechanism -- privileged = true \ # With this parameter, the root in the iner has the true root permission-V/opt/tomcat/setenv. SH:/opt/tomcat-8.5.32/bin/setenv. sh-V/opt/tomcat/tomcat-users.xml:/opt/tomcat-8.5.32/CONF/tomcat-users.xml-V/opt/tomcat/server. XML:/opt/tomcat-8.5.32/CONF/server. XML-V/opt/tomcat/logs:/opt/tomcat-8.5.32/logs-V/opt/tomcat/output: /opt/tomcat-8.5.32/output-V/opt/tomcat/webapps:/opt/tomcat-8.5.32/webapps-V/opt/tomcat/dump: /opt/tomcat-8.5.32/Dump-D taomeng/jdk8-tomcat8: 1.0
Create a tomcat Image Using docker