dockerfile
Dockerfile Docker image is used to construct the build file, the script is a series of commands and configuration parameters
Dockerfile script is a series of commands and parameters constituted these commands to the base image and ultimately create a new image. They simplify the process from start to finish and greatly simplifies deployment. Dockerfile FROM command from the start, followed by followers of the various methods, commands and parameters. Its output was a mirror can be used to create a new container.
Docker reserved word instruction
FROM base image, a new image is based on which the current mirror
MAINTAINER mirror maintainer name and email address
Command needs to be run when building RUN container
CMD command to specify a container when you start to run (Dockerfile can have multiple CMD command, but only the last one will work, CMD parameter will be replaced after the docker run)
ENTRYPOINT the specified command when a container starts to run (ENTRYPOINT purpose and CMD, are in the specified container and start the program parameters)
EXPOSE expose the external current container port
ENV environment variables to set the process to build the mirror
ADD host file in the directory image and copied into the ADD command processing URL and automatically extract the tar archive
Similarly COPY ADD, copy files and directories to the mirror. ( File directory from the building context <source path> / directory to <destination path> location within the new mirror layer )
VOLUME container data volume, and for persistent data storage operation (for setting the contents of the directory stored in the container instead of the host)
USER user account is used to set the command is run. P77
WORKDIR specified after the container is created, the default terminal landing came in the working directory.
ONBUILD run a command when building an inherited Dockerfile, the father of the mirror is triggered after the quilt in his father's image of onbuild
Custom customized tomcat
Under / xiaohua / tomcat8 directory have two packets
dockerfile file contents
CentOS the FROM the MAINTAINER on xiaohua <xhds @ 126 .com> # current context of the host to copy c.txt container / usr / local / lower path COPY c.txt / usr / local / cincontainer.txt # added to java and tomcat vessel the ADD JDK -8u241-Linux-x64.tar.gz / usr / local / the ADD Apache -tomcat- 8.5 . 53 is .tar.gz / usr / local / # vim editor mounting the RUN yum - Y vim the install # set work WORKDIR path access time, log foothold ENV MYPATH / usr / local WORKDIR $ MYPATH # java and tomcat configuration environment variable ENV JAVA_HOME / usr / local / jdk1. 8 .0_241 The CLASSPATH the JAVA_HOME $ ENV /lib/dt.jar:$JAVA_HOME/lib/ the tools.jar ENV CATALINA_HOME / usr / local / tomcat--Apache 8.5 . 53 is ENV CATALINA_BASE / usr / local / tomcat--Apache 8.5 . 53 is ENV the PATH $ the PATH: $ JAVA_HOME / bin: $ CATALINA_HOME / lib: $ CATALINA_HOME / bin listening # runtime container port EXPOSE 8080 running tomcat start time # # EntryPoint [ " /usr/local/apache-tomcat-8.5.53/bin/startup .sh " ] # CMD [ " /usr/local/apache-tomcat-8.5.53/bin/catalina.sh " , " RUN " ] CMD / usr / local / Apache-tomcat-8.5.53/bin/startup.sh && tail -F /usr/local/apache-tomcat-8.5.53/bin/logs/catalina.out
Build -f Docker / xiaohua / tomcat8 / dockerfile -t tomcat8. // build the image file
docker run -d -p 9080:8080 --name tomcat666
-v /xiaohua/mydockerfile/tomcat9/test:/usr/local/apache-tomcat-8.5.53/webapps/test
-v /xiaohua/mydockerfile/tomcat9/tomcat9logs/:/usr/local/apache-tomcat-8.5.53/logs --privileged=true tomcat8