docker 构建镜像拉取镜像生成实例
实战tomcat镜像
准备镜像文件
编写dockerfile
首先将tomcat和jdk软件包上传
创建tomcat文件夹,将文件传送到tomcat文件夹 创建Dockerfile(不用加-f指定)文件
add自动解压
jdk与apache在云服务器
构建镜像
[root@docker tomcat]# cat Dockerfile
FROM centos:7
MAINTAINER MQY2567169491@qq.com
COPY redme.txt /usr/local/redme.txt
ADD jdk-8u271-linux-x64.tar.gz /usr/local
ADD apache-tomcat-9.0.56.tar.gz /usr/local
RUN yum -y install vim
ENV MYPATH /usr/local
WORKDIR $MYPATH
ENV JAVA_HOME /usr/local/jdk1.8.0_271/
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.56
ENV CATALINA_BASH /usr/local/apache-tomcat-9.0.56
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin
EXPOSE 8080
CMD /usr/local/apache-tomcat-9.0.56/bin/startup.sh && tail -F /usr/local/usr/local/tomcat-9.0.56/bin/logs/catalina.out
[root@docker tomcat]#
寻找docker启动失败的错误
docker logs $(docker ps -aq)
启动tomcat实例
docker run -d -p 9090:8080 --name cfaa -v /home/dockerfile/tomcat/test/:/usl/local/apache-tomcat-9.0.56/webapps/test -v /home/dockerfile/tomcat/tomcatlogs/:/usr/local/apache-tomcat-9.0.56/logs abcx
curl localhost:9090
通过修改挂载出来的目录 改变网页