2017-09-04 193 views
2

我在Docker中運行Tomee7。日誌說它開始了,但我無法在瀏覽器中看到。爲什麼在Docker環境中運行TomEE時無法訪問?

我試圖與本地主機:8080,也與碼頭工人IP 192.168.99.100:8080

Tomee登錄:

INFO - Creating Container(id=My Stateless Container) 
INFO - Creating ServerService(id=cxf) 
INFO - Creating ServerService(id=cxf-rs) 
INFO - ** Bound Services ** 
INFO - NAME     IP    PORT 
INFO - ------- 
INFO - Ready! 
INFO - Initialization processed in 2663 ms 
INFO - Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'. 
INFO - Creating Resource(id=UserDatabase) 
INFO - Starting service Catalina 
INFO - Starting Servlet Engine: Apache Tomcat (TomEE)/8.5.3 (7.0.1) 
INFO - Deploying web application directory /home/test/apache-tomee-plus-7.0.1/webapps/ROOT 
INFO - ------------------------- localhost ->/
INFO - Configuring enterprise application: /home/test/apache-tomee-plus-7.0.1/webapps/ROOT 
INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) 
INFO - Auto-creating a container for bean .Comp131040203: Container(type=MANAGED, id=Default Managed Container) 
INFO - Creating Container(id=Default Managed Container) 
INFO - Using directory /home/test/apache-tomee-plus-7.0.1/temp for stateful session passivation 
INFO - Enterprise application "/home/test/apache-tomee-plus-7.0.1/webapps/ROOT" loaded. 
INFO - Assembling app: /home/test/apache-tomee-plus-7.0.1/webapps/ROOT 
INFO - Deployed Application(path=/home/test/apache-tomee-plus-7.0.1/webapps/ROOT) 
INFO - 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. 
INFO - Deployment of web application directory /home/test/apache-tomee-plus-7.0.1/webapps/ROOT has finished in 729 ms 
INFO - Starting ProtocolHandler [http-apr-80] 
INFO - Starting ProtocolHandler [https-openssl-apr-8443] 
INFO - Server startup in 813 ms 

泊塢窗PS日誌:

$ docker ps 
CONTAINER ID  IMAGE    COMMAND     CREATED    STATUS    PORTS     NAMES 
e7727df4619b  tomee7    "/bin/sh -c '${TOM..." 2 minutes ago  Up 2 minutes  0.0.0.0:8080->8080/tcp tomee7 

泊塢窗機:

$ docker-machine ls 
NAME  ACTIVE DRIVER  STATE  URL       SWARM DOCKER  ERRORS 
default *  virtualbox Running tcp://192.168.99.100:2376   v17.06.0-ce 

tomee服務器:ifconfig日誌

$ docker exec -it tomee7 /bin/bash 
[email protected]:/home/test# ifconfig 
eth0  Link encap:Ethernet HWaddr 02:42:ac:11:00:02 
      inet addr:172.17.0.2 Bcast:0.0.0.0 Mask:255.255.0.0 
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
      RX packets:10 errors:0 dropped:0 overruns:0 frame:0 
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
      collisions:0 txqueuelen:0 
      RX bytes:828 (828.0 B) TX bytes:0 (0.0 B) 

lo  Link encap:Local Loopback 
      inet addr:127.0.0.1 Mask:255.0.0.0 
      UP LOOPBACK RUNNING MTU:65536 Metric:1 
      RX packets:4 errors:0 dropped:0 overruns:0 frame:0 
      TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 
      collisions:0 txqueuelen:1 
      RX bytes:200 (200.0 B) TX bytes:200 (200.0 B) 

回答

0

Tomcat啓動日誌說:INFO - Starting ProtocolHandler [http-apr-80]。我建議tomcat聽80端口。但是你公開了8080端口。

有兩種方法可以修復它:公開80端口(進入碼頭集裝箱)。或者更改tomcat偵聽端口。

你能告訴我請Dockerfile嗎?我嘗試修復它。

+0

上午使用直接運行命令,像這個碼頭運行-it -p 8888:8888 --name tomee7 tomee7 – Ashish451

0

看來你在虛擬機裏面的虛擬機上運行Docker。您需要在VM上配置端口轉發。

如果您打開虛擬機設置並選擇網絡,應該有一個選項來配置端口轉發。您可以谷歌截圖或視頻顯示如何做到這一點,只要確保您使用正確的端口號。

相關問題