在上一篇文章中介绍了利用Dockerfile创建docker镜像文件,编写的过程中把jdk和tomcat文件都加入到镜像文件中去了。通过以下命令来启动镜像文件。
[root
@localhost docker]
REPOSITORY TAG IMAGE ID CREATED SIZE
centos base
9d20362732d7
About an hour ago
904.8 MB
docker.io/centos latest
970633036444 2 weeks ago
196.7 MB
[root
@localhost soft]
0299abe0d2c9e97ac00337e4df344b1000956d4e4e8eb11a810cc586a226ad36
[root
@localhost docker]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0299abe0d2c9
centos:base
"/bin/bash" 12 minutes ago
Up 12 minutes
0.
0.
0.
0:80->
8080/tcp mytomcat
[root
@localhost soft]
[root
@0299abe0d2c9 /]
bash: /usr/app/jdk/
bin:/usr/local/
sbin:/usr/local/
bin:/usr/
sbin:/usr/
bin:/
sbin:/
bin: No such file
or directory
[root
@0299abe0d2c9 /]
java version
"1.8.0_102"
Java(
TM)
SE Runtime Environment (build
1.8.
0_102-b14)
Java HotSpot(
TM)
64-
Bit Server VM (build
25.102-b14, mixed mode)
[root
@0299abe0d2c9 /]
[root
@0299abe0d2c9 app]
total
12
drwxr-xr-x.
9 root root
4096 Aug 15 06:23 hadoop
drwxr-xr-x.
8 root root
4096 Aug 15 06:23 jdk
drwxr-xr-x.
9 root root
4096 Aug 15 06:23 tomcat
将目录切换到tomcat的Bin目录下,运行startup.sh启动tomcat服务即可。
[root
@0299abe0d2c9 bin]
# ./startup.sh
Tomcat started.
[root
@0299abe0d2c9 tomcat]
# tail -f ../logs/catalina.out
15-Aug-
2016 07:
57:
19.668 INFO [localhost-startStop-
1] org
.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/app/tomcat/webapps/docs has finished
in 17 ms
15-Aug-
2016 07:
57:
19.668 INFO [localhost-startStop-
1] org
.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/app/tomcat/webapps/examples
15-Aug-
2016 07:
57:
20.096 INFO [localhost-startStop-
1] org
.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/app/tomcat/webapps/examples has finished
in 428 ms
15-Aug-
2016 07:
57:
20.096 INFO [localhost-startStop-
1] org
.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/app/tomcat/webapps/host-manager
15-Aug-
2016 07:
57:
20.123 INFO [localhost-startStop-
1] org
.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/app/tomcat/webapps/host-manager has finished
in 27 ms
15-Aug-
2016 07:
57:
20.123 INFO [localhost-startStop-
1] org
.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/app/tomcat/webapps/manager
15-Aug-
2016 07:
57:
20.148 INFO [localhost-startStop-
1] org
.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/app/tomcat/webapps/manager has finished
in 24 ms
15-Aug-
2016 07:
57:
20.152 INFO [main] org
.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-
8080]
15-Aug-
2016 07:
57:
20.160 INFO [main] org
.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-
8009]
15-Aug-
2016 07:
57:
20.163 INFO [main] org
.apache.catalina.startup.Catalina.start Server startup
in 985 ms
在主机环境下输入http://localhost即可看到熟悉的tomcat界面。
转载请注明原文地址: https://ju.6miu.com/read-1303689.html