91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

docker容器如何掛載宿主主機目錄

發布時間:2021-08-21 11:33:51 來源:億速云 閱讀:522 作者:小新 欄目:服務器

這篇文章將為大家詳細講解有關docker容器如何掛載宿主主機目錄,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

有一項重要的參數 -v 目錄掛載,就是讓容器內部目錄和宿主主機目錄關聯起來,這樣就可以直接操作宿主主機目錄而不用再操作具體容器了

比如在2中,我們要發布一個war包,是通過 

sudo docker cp demo.war tomcat_xiao:/usr/local/tomcat/webapps

 來發布的,有沒有更快捷的方式呢?

肯定有, 沒有 我就不會在這里寫這些玩意兒了

sudo docker run -p 8822:8080 --name tomcat_xiao_volume -v /home/xiaochangwei/test:/usr/local/tomcat/webapps xiaochangwei/tomcat:v1

  -p     不解釋
  --name   不解釋
   -v /home/xiaochangwei/test:/usr/local/tomcat/webapps 就是將宿主主機目錄和容器目錄建立映射關系,冒號前為宿主主機目錄,冒號后為容器對應目錄

  執行上面的命令啟動,這次啟動就和上一篇文章中的啟動日志有點差異了:差異就在容器啟動時,tomcat加載了我們映射的宿主主機目錄中的war包

xiaochangwei@ubuntu:~/test$ sudo docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS       PORTS        NAMES
xiaochangwei@ubuntu:~/test$ sudo docker images
REPOSITORY      TAG         IMAGE ID      CREATED       SIZE
xiaochangwei/tomcat  v1         62cedd29ce8f    About an hour ago  505MB
xiaochangwei/nginx  v1.0        9f2c1a649a75    2 hours ago     108MB
nginx         latest       3f8a4339aadd    9 days ago     108MB
ubuntu        16.04        00fd29ccc6f1    3 weeks ago     111MB
xiaochangwei@ubuntu:~/test$ 
xiaochangwei@ubuntu:~/test$ pwd
/home/xiaochangwei/test
xiaochangwei@ubuntu:~/test$ ls -l
total 14180
-rw-rw-r-- 1 xiaochangwei xiaochangwei 14501238 Dec 19 23:29 demo.war
-rw-rw-r-- 1 xiaochangwei xiaochangwei   551 Jan 4 18:18 Dockerfile
drwxr-xr-x 8 xiaochangwei xiaochangwei   4096 Dec 12 2016 jdk
drwxrwxr-x 6 xiaochangwei xiaochangwei   4096 Dec 20 21:51 maven
drwxrwxr-x 9 xiaochangwei xiaochangwei   4096 Dec 20 18:28 tomcat
xiaochangwei@ubuntu:~/test$ sudo docker run -p 8822:8080 --name tomcat_xiao_volume -v /home/xiaochangwei/test:/usr/local/tomcat/webapps xiaochangwei/tomcat:v1
Tomcat started.
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=64M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
05-Jan-2018 08:32:20.580 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:    Apache Tomcat/8.5.24
05-Jan-2018 08:32:20.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:     Nov 27 2017 13:05:30 UTC
05-Jan-2018 08:32:20.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:     8.5.24.0
05-Jan-2018 08:32:20.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:        Linux
05-Jan-2018 08:32:20.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:      4.10.0-28-generic
05-Jan-2018 08:32:20.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:     amd64
05-Jan-2018 08:32:20.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:       /usr/local/jdk/jre
05-Jan-2018 08:32:20.642 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:      1.8.0_121-b13
05-Jan-2018 08:32:20.642 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:      Oracle Corporation
05-Jan-2018 08:32:20.642 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:     /usr/local/tomcat
05-Jan-2018 08:32:20.642 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:     /usr/local/tomcat
05-Jan-2018 08:32:20.642 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
05-Jan-2018 08:32:20.648 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
05-Jan-2018 08:32:20.648 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
05-Jan-2018 08:32:20.648 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
05-Jan-2018 08:32:20.648 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
05-Jan-2018 08:32:20.648 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx1024m
05-Jan-2018 08:32:20.648 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:PermSize=64M
05-Jan-2018 08:32:20.648 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:MaxPermSize=512M
05-Jan-2018 08:32:20.648 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
05-Jan-2018 08:32:20.649 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
05-Jan-2018 08:32:20.649 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
05-Jan-2018 08:32:20.649 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
05-Jan-2018 08:32:20.649 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
05-Jan-2018 08:32:21.293 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
05-Jan-2018 08:32:21.358 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
05-Jan-2018 08:32:21.370 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
05-Jan-2018 08:32:21.374 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
05-Jan-2018 08:32:21.375 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 2178 ms
05-Jan-2018 08:32:21.432 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
05-Jan-2018 08:32:21.432 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.24
05-Jan-2018 08:32:21.513 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/tomcat/webapps/demo.war]
05-Jan-2018 08:32:24.342 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
08:32:24.799 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletConfigInitParams' with lowest search precedence
08:32:24.813 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletContextInitParams' with lowest search precedence
08:32:24.832 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'jndiProperties' with lowest search precedence
08:32:24.832 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemProperties' with lowest search precedence
08:32:24.832 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemEnvironment' with lowest search precedence
08:32:24.833 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [StubPropertySource@1897128678 {name='servletConfigInitParams', properties=java.lang.Object@6b18d91f}, StubPropertySource@1347718626 {name='servletContextInitParams', properties=java.lang.Object@4ba81d05}, JndiPropertySource@633520708 {name='jndiProperties', properties=org.springframework.jndi.JndiLocatorDelegate@83f37c2}, MapPropertySource@2087751866 {name='systemProperties', properties={java.runtime.name=Java(TM) SE Runtime Environment, java.protocol.handler.pkgs=org.apache.catalina.webresources, sun.boot.library.path=/usr/local/jdk/jre/lib/amd64, java.vm.version=25.121-b13, shared.loader=, java.vm.vendor=Oracle Corporation, java.vendor.url=http://java.oracle.com/, path.separator=:, tomcat.util.buf.StringCache.byte.enabled=true, java.util.logging.config.file=/usr/local/tomcat/conf/logging.properties, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, file.encoding.pkg=sun.io, user.country=US, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=unknown, tomcat.util.scan.StandardJarScanFilter.jarsToScan=log4j-web*.jar,log4j-taglib*.jar,log4javascript*.jar,slf4j-taglib*.jar, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/, java.runtime.version=1.8.0_121-b13, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/usr/local/jdk/jre/lib/endorsed, os.arch=amd64, java.io.tmpdir=/usr/local/tomcat/temp, line.separator=
, java.vm.specification.vendor=Oracle Corporation, java.naming.factory.url.pkgs=org.apache.naming, java.util.logging.manager=org.apache.juli.ClassLoaderLogManager, os.name=Linux, ignore.endorsed.dirs=, sun.jnu.encoding=ANSI_X3.4-1968, java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib, java.specification.name=Java Platform API Specification, java.class.version=52.0, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, os.version=4.10.0-28-generic, java.util.concurrent.ForkJoinPool.common.threadFactory=org.apache.catalina.startup.SafeForkJoinWorkerThreadFactory, user.home=/root, catalina.useNaming=true, user.timezone=Etc/UTC, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=ANSI_X3.4-1968, java.specification.version=1.8, tomcat.util.scan.StandardJarScanFilter.jarsToSkip=bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,jaspic-api.jar,catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-storeconfig.jar,catalina-tribes.jar,jasper.jar,jasper-el.jar,ecj-*.jar,tomcat-api.jar,tomcat-util.jar,tomcat-util-scan.jar,tomcat-coyote.jar,tomcat-dbcp.jar,tomcat-jni.jar,tomcat-websocket.jar,tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,tomcat-jdbc.jar,tools.jar,commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,commons-math*.jar,commons-pool*.jar,jstl.jar,taglibs-standard-spec-*.jar,geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h3*.jar,hibernate*.jar,httpclient*.jar,jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,junit.jar,junit-*.jar,hamcrest-*.jar,easymock-*.jar,cglib-*.jar,objenesis-*.jar,ant-launcher.jar,cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,xom-*.jar, catalina.home=/usr/local/tomcat, java.class.path=/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar, user.name=root, java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.naming.,org.apache.tomcat., java.vm.specification.version=1.8, sun.java.command=org.apache.catalina.startup.Bootstrap start, java.home=/usr/local/jdk/jre, sun.arch.data.model=64, user.language=en, java.specification.vendor=Oracle Corporation, awt.toolkit=sun.awt.X11.XToolkit, java.vm.info=mixed mode, java.version=1.8.0_121, java.ext.dirs=/usr/local/jdk/jre/lib/ext:/usr/java/packages/lib/ext, sun.boot.class.path=/usr/local/jdk/jre/lib/resources.jar:/usr/local/jdk/jre/lib/rt.jar:/usr/local/jdk/jre/lib/sunrsasign.jar:/usr/local/jdk/jre/lib/jsse.jar:/usr/local/jdk/jre/lib/jce.jar:/usr/local/jdk/jre/lib/charsets.jar:/usr/local/jdk/jre/lib/jfr.jar:/usr/local/jdk/jre/classes, server.loader=, java.vendor=Oracle Corporation, catalina.base=/usr/local/tomcat, jdk.tls.ephemeralDHKeySize=2048, file.separator=/, java.vendor.url.bug=http://bugreport.sun.com/bugreport/, common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar", sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.tomcat., sun.cpu.isalist=}}, SystemEnvironmentPropertySource@2000415236 {name='systemEnvironment', properties={PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk/bin:/usr/local/maven/bin, JRE_HOME=/usr/local/jdk/jre, HOSTNAME=2dcd945938e8, NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat, M2_HOME=/usr/local/maven, JAVA_HOME=/usr/local/jdk, CATALINA_OPTS=-Xms128m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=512M, JDK_JAVA_OPTIONS= --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED, XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt, PWD=/, CLASSPATH=/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar, HOME=/root}}]
08:32:24.844 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Replacing PropertySource 'servletContextInitParams' with 'servletContextInitParams'
 .  ____     _      __ _ _
 /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/ ___)| |_)| | | | | || (_| | ) ) ) )
 ' |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::    (v1.5.9.RELEASE)
2018-01-05 08:32:26.068 INFO 13 --- [ost-startStop-1] com.example.demo.ServletInitializer   : Starting ServletInitializer v0.0.1-SNAPSHOT on 2dcd945938e8 with PID 13 (/usr/local/tomcat/webapps/demo/WEB-INF/classes started by root in /)
2018-01-05 08:32:26.180 INFO 13 --- [ost-startStop-1] com.example.demo.ServletInitializer   : No active profile set, falling back to default profiles: default
2018-01-05 08:32:26.357 INFO 13 --- [ost-startStop-1] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@77b0904a: startup date [Fri Jan 05 08:32:26 UTC 2018]; root of context hierarchy
2018-01-05 08:32:28.732 INFO 13 --- [ost-startStop-1] o.s.web.context.ContextLoader      : Root WebApplicationContext: initialization completed in 2374 ms
2018-01-05 08:32:29.920 INFO 13 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-01-05 08:32:29.930 INFO 13 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'errorPageFilter' to: [/*]
2018-01-05 08:32:29.934 INFO 13 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-05 08:32:29.935 INFO 13 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-01-05 08:32:29.935 INFO 13 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-01-05 08:32:29.935 INFO 13 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2018-01-05 08:32:30.900 INFO 13 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@77b0904a: startup date [Fri Jan 05 08:32:26 UTC 2018]; root of context hierarchy
2018-01-05 08:32:31.079 INFO 13 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/test]}" onto public java.lang.String com.example.demo.web.TEst.test()
2018-01-05 08:32:31.084 INFO 13 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-01-05 08:32:31.091 INFO 13 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-01-05 08:32:31.185 INFO 13 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-05 08:32:31.186 INFO 13 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-05 08:32:31.302 INFO 13 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-05 08:32:31.667 INFO 13 --- [ost-startStop-1] o.s.j.e.a.AnnotationMBeanExporter    : Registering beans for JMX exposure on startup
2018-01-05 08:32:31.699 INFO 13 --- [ost-startStop-1] com.example.demo.ServletInitializer   : Started ServletInitializer in 6.843 seconds (JVM running for 13.352)
05-Jan-2018 08:32:31.792 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/demo.war] has finished in [10,278] ms
05-Jan-2018 08:32:31.793 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/tomcat]
05-Jan-2018 08:32:31.846 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/tomcat] has finished in [52] ms
05-Jan-2018 08:32:31.846 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/maven]
05-Jan-2018 08:32:31.874 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/maven] has finished in [27] ms
05-Jan-2018 08:32:31.878 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/jdk]
05-Jan-2018 08:32:31.919 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/jdk] has finished in [41] ms
05-Jan-2018 08:32:31.926 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
05-Jan-2018 08:32:31.958 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
05-Jan-2018 08:32:31.980 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 10604 ms

按照說明,如果在宿主主機的目錄中再放一個war包,容器也應該自動部署,下面驗證下

為了方便,我直接復制了demo.war

xiaochangwei@ubuntu:~/test$ ls -l
total 14184
drwxr-x--- 5 root     root       4096 Jan 5 00:32 demo
-rw-rw-r-- 1 xiaochangwei xiaochangwei 14501238 Dec 19 23:29 demo.war
-rw-rw-r-- 1 xiaochangwei xiaochangwei   551 Jan 4 18:18 Dockerfile
drwxr-xr-x 8 xiaochangwei xiaochangwei   4096 Dec 12 2016 jdk
drwxrwxr-x 6 xiaochangwei xiaochangwei   4096 Dec 20 21:51 maven
drwxrwxr-x 9 xiaochangwei xiaochangwei   4096 Dec 20 18:28 tomcat
xiaochangwei@ubuntu:~/test$ 
xiaochangwei@ubuntu:~/test$ 
xiaochangwei@ubuntu:~/test$ cp -p demo.war demo2.war
xiaochangwei@ubuntu:~/test$ ll
total 28360
drwxrwxr-x 7 xiaochangwei xiaochangwei   4096 Jan 5 00:41 ./
drwxr-xr-x 18 xiaochangwei xiaochangwei   4096 Dec 20 23:01 ../
drwxr-x--- 5 root     root       4096 Jan 5 00:32 demo/
drwxr-x--- 5 root     root       4096 Jan 5 00:41 demo2/
-rw-rw-r-- 1 xiaochangwei xiaochangwei 14501238 Dec 19 23:29 demo2.war
-rw-rw-r-- 1 xiaochangwei xiaochangwei 14501238 Dec 19 23:29 demo.war
-rw-rw-r-- 1 xiaochangwei xiaochangwei   551 Jan 4 18:18 Dockerfile
drwxr-xr-x 8 xiaochangwei xiaochangwei   4096 Dec 12 2016 jdk/
drwxrwxr-x 6 xiaochangwei xiaochangwei   4096 Dec 20 21:51 maven/
drwxrwxr-x 9 xiaochangwei xiaochangwei   4096 Dec 20 18:28 tomcat/
xiaochangwei@ubuntu:~/test$

然后看容器的控制臺:

05-Jan-2018 08:32:31.926 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
05-Jan-2018 08:32:31.958 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
05-Jan-2018 08:32:31.980 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 10604 ms
05-Jan-2018 08:41:22.174 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/tomcat/webapps/demo2.war]
2018-01-05 08:41:23.862 INFO 13 --- [ost-startStop-2] org.apache.jasper.servlet.TldScanner   : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
08:41:24.163 [localhost-startStop-2] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletConfigInitParams' with lowest search precedence
08:41:24.165 [localhost-startStop-2] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletContextInitParams' with lowest search precedence
08:41:24.173 [localhost-startStop-2] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'jndiProperties' with lowest search precedence
08:41:24.178 [localhost-startStop-2] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemProperties' with lowest search precedence
08:41:24.178 [localhost-startStop-2] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemEnvironment' with lowest search precedence
08:41:24.178 [localhost-startStop-2] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [StubPropertySource@165669309 {name='servletConfigInitParams', properties=java.lang.Object@2636bd14}, StubPropertySource@1385884584 {name='servletContextInitParams', properties=java.lang.Object@33ec3b2}, JndiPropertySource@1968853097 {name='jndiProperties', properties=org.springframework.jndi.JndiLocatorDelegate@66178dcb}, MapPropertySource@1666575626 {name='systemProperties', properties={java.vendor=Oracle Corporation, sun.java.launcher=SUN_STANDARD, catalina.base=/usr/local/tomcat, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, catalina.useNaming=true, os.name=Linux, sun.boot.class.path=/usr/local/jdk/jre/lib/resources.jar:/usr/local/jdk/jre/lib/rt.jar:/usr/local/jdk/jre/lib/sunrsasign.jar:/usr/local/jdk/jre/lib/jsse.jar:/usr/local/jdk/jre/lib/jce.jar:/usr/local/jdk/jre/lib/charsets.jar:/usr/local/jdk/jre/lib/jfr.jar:/usr/local/jdk/jre/classes, java.util.logging.config.file=/usr/local/tomcat/conf/logging.properties, java.vm.specification.vendor=Oracle Corporation, java.runtime.version=1.8.0_121-b13, user.name=root, tomcat.util.scan.StandardJarScanFilter.jarsToScan=log4j-web*.jar,log4j-taglib*.jar,log4javascript*.jar,slf4j-taglib*.jar, shared.loader=, tomcat.util.buf.StringCache.byte.enabled=true, user.language=en, java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, sun.boot.library.path=/usr/local/jdk/jre/lib/amd64, PID=13, jdk.tls.ephemeralDHKeySize=2048, java.version=1.8.0_121, java.util.logging.manager=org.apache.juli.ClassLoaderLogManager, user.timezone=Etc/UTC, sun.arch.data.model=64, java.util.concurrent.ForkJoinPool.common.threadFactory=org.apache.catalina.startup.SafeForkJoinWorkerThreadFactory, java.endorsed.dirs=/usr/local/jdk/jre/lib/endorsed, sun.cpu.isalist=, sun.jnu.encoding=ANSI_X3.4-1968, file.encoding.pkg=sun.io, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.tomcat., file.separator=/, java.specification.name=Java Platform API Specification, java.class.version=52.0, user.country=US, java.home=/usr/local/jdk/jre, java.vm.info=mixed mode, os.version=4.10.0-28-generic, path.separator=:, java.vm.version=25.121-b13, org.jboss.logging.provider=slf4j, java.protocol.handler.pkgs=org.apache.catalina.webresources, java.awt.printerjob=sun.print.PSPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.X11.XToolkit, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.naming.,org.apache.tomcat., java.naming.factory.url.pkgs=org.apache.naming, user.home=/root, java.specification.vendor=Oracle Corporation, tomcat.util.scan.StandardJarScanFilter.jarsToSkip=bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,jaspic-api.jar,catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-storeconfig.jar,catalina-tribes.jar,jasper.jar,jasper-el.jar,ecj-*.jar,tomcat-api.jar,tomcat-util.jar,tomcat-util-scan.jar,tomcat-coyote.jar,tomcat-dbcp.jar,tomcat-jni.jar,tomcat-websocket.jar,tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,tomcat-jdbc.jar,tools.jar,commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,commons-math*.jar,commons-pool*.jar,jstl.jar,taglibs-standard-spec-*.jar,geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h3*.jar,hibernate*.jar,httpclient*.jar,jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,junit.jar,junit-*.jar,hamcrest-*.jar,easymock-*.jar,cglib-*.jar,objenesis-*.jar,ant-launcher.jar,cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,xom-*.jar, java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib, java.vendor.url=http://java.oracle.com/, spring.beaninfo.ignore=true, java.vm.vendor=Oracle Corporation, common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar", java.runtime.name=Java(TM) SE Runtime Environment, sun.java.command=org.apache.catalina.startup.Bootstrap start, java.class.path=/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.8, catalina.home=/usr/local/tomcat, sun.cpu.endian=little, sun.os.patch.level=unknown, java.awt.headless=true, java.io.tmpdir=/usr/local/tomcat/temp, java.vendor.url.bug=http://bugreport.sun.com/bugreport/, server.loader=, os.arch=amd64, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.ext.dirs=/usr/local/jdk/jre/lib/ext:/usr/java/packages/lib/ext, user.dir=/, line.separator=
, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, ignore.endorsed.dirs=, file.encoding=ANSI_X3.4-1968, java.specification.version=1.8}}, SystemEnvironmentPropertySource@377717121 {name='systemEnvironment', properties={PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk/bin:/usr/local/maven/bin, JRE_HOME=/usr/local/jdk/jre, HOSTNAME=2dcd945938e8, NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat, M2_HOME=/usr/local/maven, JAVA_HOME=/usr/local/jdk, CATALINA_OPTS=-Xms128m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=512M, JDK_JAVA_OPTIONS= --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED, XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt, PWD=/, CLASSPATH=/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar, HOME=/root}}]
08:41:24.181 [localhost-startStop-2] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Replacing PropertySource 'servletContextInitParams' with 'servletContextInitParams'
 .  ____     _      __ _ _
 /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/ ___)| |_)| | | | | || (_| | ) ) ) )
 ' |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::    (v1.5.9.RELEASE)
2018-01-05 08:41:25.139 INFO 13 --- [ost-startStop-2] com.example.demo.ServletInitializer   : Starting ServletInitializer v0.0.1-SNAPSHOT on 2dcd945938e8 with PID 13 (/usr/local/tomcat/webapps/demo2/WEB-INF/classes started by root in /)
2018-01-05 08:41:25.140 INFO 13 --- [ost-startStop-2] com.example.demo.ServletInitializer   : No active profile set, falling back to default profiles: default
2018-01-05 08:41:25.292 INFO 13 --- [ost-startStop-2] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7d220249: startup date [Fri Jan 05 08:41:25 UTC 2018]; root of context hierarchy
2018-01-05 08:41:27.126 INFO 13 --- [ost-startStop-2] o.s.web.context.ContextLoader      : Root WebApplicationContext: initialization completed in 1834 ms
2018-01-05 08:41:28.082 INFO 13 --- [ost-startStop-2] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-01-05 08:41:28.083 INFO 13 --- [ost-startStop-2] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'errorPageFilter' to: [/*]
2018-01-05 08:41:28.084 INFO 13 --- [ost-startStop-2] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-05 08:41:28.084 INFO 13 --- [ost-startStop-2] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-01-05 08:41:28.084 INFO 13 --- [ost-startStop-2] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-01-05 08:41:28.084 INFO 13 --- [ost-startStop-2] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2018-01-05 08:41:28.924 INFO 13 --- [ost-startStop-2] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7d220249: startup date [Fri Jan 05 08:41:25 UTC 2018]; root of context hierarchy
2018-01-05 08:41:29.087 INFO 13 --- [ost-startStop-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/test]}" onto public java.lang.String com.example.demo.web.TEst.test()
2018-01-05 08:41:29.099 INFO 13 --- [ost-startStop-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-01-05 08:41:29.100 INFO 13 --- [ost-startStop-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-01-05 08:41:29.181 INFO 13 --- [ost-startStop-2] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-05 08:41:29.181 INFO 13 --- [ost-startStop-2] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-05 08:41:29.296 INFO 13 --- [ost-startStop-2] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-05 08:41:29.591 INFO 13 --- [ost-startStop-2] o.s.j.e.a.AnnotationMBeanExporter    : Registering beans for JMX exposure on startup
2018-01-05 08:41:29.616 INFO 13 --- [ost-startStop-2] com.example.demo.ServletInitializer   : Started ServletInitializer in 5.421 seconds (JVM running for 551.268)
05-Jan-2018 08:41:29.632 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/demo2.war] has finished in [7,459] ms

證明我們的猜想和實際情況是一致的

這樣,我們就可以在宿主主機下根據不同的容器建立對應的便于記憶的目錄路徑,有發布需求的時候,直接將war包拷貝到宿主主機目錄即可,容器叫什么名字,對應的容器的發布路徑在哪里就與發布

關于“docker容器如何掛載宿主主機目錄”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

南岸区| 同江市| 共和县| 敖汉旗| 阳原县| 法库县| 景东| 鹤壁市| 奈曼旗| 青神县| 葫芦岛市| 福泉市| 托里县| 慈溪市| 石屏县| 梅河口市| 浏阳市| 奇台县| 彰武县| 潍坊市| 高台县| 湘西| 五寨县| 文成县| 赤峰市| 勃利县| 滦平县| 方山县| 贵南县| 灌阳县| 漠河县| 宁强县| 安仁县| 鄂托克旗| 临泽县| 富阳市| 佛学| 垫江县| 桓仁| 镇赉县| 西乌珠穆沁旗|