目录
1.自定义centos,具备vim及ifconfig作用
2.自定义tomcat8
1.自定义centos,具备vim及ifconfig作用
cd /javaxl/software
mkdir mydocker
vi mycentosDockerfile
向 mycentosDockerfile 编辑内容
FROM centos:7
MAINTAINER zwc "zwc@qq.com"
RUN yum -y install vim
RUN yum install net-tools.x86_64 -y
CMD /bin/bash
构建镜像
docker build -f mycentosDockerfile -t javaxl/centos:v1.0 .
通过镜像运行一个容器进行测试
docker run -it --name mc1 javaxl/centos:v1.0 /bin/bash
2.自定义tomcat8
cd /javaxl/software
mkdir mydocker
vi mytomcatDockerfile
向 mytomcatDockerfile 编辑内容
FROM centos:7
MAINTAINER zwc"zwc@qq.com"
ENV workerDir /home/zwc/dockerfile/3
WORKDIR $workerDir
ADD jdk-8u151-linux-x64.tar.gz $workerDir
COPY apache-tomcat-8.5.20.tar.gz $workerDir
RUN tar -xvf apache-tomcat-8.5.20.tar.gz apache-tomcat-8.5.20
ENV JAVA_HOME $workerDir/jdk1.8.0_151
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV TOMCAT_HOME $workerDir/apache-tomcat-8.5.20
ENV PATH $JAVA_HOME/bin:$TOMCAT_HOME/bin:$TOMCAT_HOME/lib:$PATH
EXPOSE 8080
ENTRYPOINT ["/home/zwc/dockerfile/3/apache-tomcat-8.5.20/bin/catalina.sh","run"]
构建镜像
docker build -f mytomcatDockerfile -t javaxl/tomcat8:v1.0 .
通过镜像运行2个容器进行测试
docker run -di --name mt1 -P javaxl/tomcat8:v1.0
docker run -di --name mt2 -P javaxl/tomcat8:v1.0