Dockerfile构建Tomcat镜像
目录
Dockerfile构建Tomcat镜像
1、建立工作目录
2、编写Dockerfile文件
3、构建镜像
4、测试容器
5、浏览器访问测试:
1、建立工作目录
[root@huyang1 ~]# mkdir tomcat
[root@huyang1 ~]# cd tomcat/
[root@huyang1 tomcat]# ls
apache-tomcat-8.5.40.tar.gz jdk-8u191-linux-x64.tar.gz
[root@huyang1 tomcat]# tar xf
jdk-8u191-linux-x64.tar.gz
[root@huyang1 tomcat]# tar xf
apache-tomcat-8.5.40.tar.gz
2、编写Dockerfile文件
[root@huyang1 tomcat]# vim Dockerfile
配置如下:
FROM centos:7
MAINTAINER Crushlinux <crushlinux@163.com>
ADD jdk1.8.0_191 /usr/local/java
ENV JAVA_HOME /usr/local/java
ENV JAVA_BIN /usr/local/java/bin
ENV JRE_HOME /usr/local/java/jre
ENV PATH $PATH:/usr/local/java/bin:/usr/local/java/jre/bin
ENV CLASSPATH /usr/local/java/jre/bin:/usr/local/java/lib:/usr/local/java/jre/lib/charsets.jar
ADD apache-tomcat-8.5.40 /usr/local/tomcat
RUN chmod 755 /usr/local/tomcat/bin/startup.sh
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
EXPOSE 8080
CMD ["/usr/local/tomcat/bin/catalina.sh", "run"]
3、构建镜像
[root@huyang1 tomcat]# docker build -t tomcat:new .
[root@huyang1 ~]# docker images tomcat:new
4、测试容器
[root@huyang1 tomcat]# docker run -d -p 8080:8080 --name tomcat-test tomcat:new
5、浏览器访问测试:
http://192.168.100.131:8080