In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to write a docker file file", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to write docker file files" bar!
1. Export the docker plug-in
1. Import the docker maven plug-in
Org.codehaus.mojo
Build-helper-maven-plugin
1.9.1
Timestamp-property
Timestamp-property
Current.time
YyyyMMddHHmmss
GMT+8
Com.spotify
Dockerfile-maven-plugin
1.4.0
Default
Install
Build
Push
Registry
******
172.16.1.146Unitek Universe ${project.artifactId}
${project.version}-${current.time}
Article title
Article classification
Target/docker-test-1.0.0.jar
2. DockerFiley file compilation
# pull the basic image
FROM hub.c.163.com/library/java:8-jdk
# author of the image
MAINTAINER csp@xxx.com
# Mount directory. The mount point created by VOLUME instruction cannot specify the corresponding directory on the host. It is automatically generated.
VOLUME ["/ data1", "/ data2"]
RUN ["mkdir", "- p", "/ app"]
# combined with the packaging of maven plug-in dockerfile-maven-plugin
ARG JAR_FILE
ADD ${JAR_FILE} / app/app.jar
# set the current working directory in the image for subsequent RUN, CMD, ENTRYPOINT, ADD or COPY instructions.
# WORKDIR / usr/local/docker/test
# copy the current directory file to container / app
# COPY. / app
# similar to COPY, copying files from build context to images. The difference is that if the src is an archive file (tar, zip, tgz, xz, etc.), the file will be automatically extracted to dest.
# ADD src dest
# set environment variables, which can be used by subsequent instructions
ENV EVN_SET_TEST "WELCOME TO DOCKERFILE CONTAINER!"
#
# RUN, CDM, ENTRYPOINT commands all contain two formats: Shell format and Exec format
# CMD can also be placed after ENTRYPOINT to pass parameters to it.
# shell format: #
# # the bottom layer will call / bin/sh-c
# run the specified command in the container
RUN echo $EVN_SET_TEST
# only the last container startup command takes effect, and CMD can be replaced by the parameter after docker run.
# only the last one takes effect
CMD echo "CMD Hello world"
# configure commands to run when the container starts up
ENTRYPOINT echo "ENTRYPOINT Hello, $EVN_SET_TEST"
# Exec format: #
# # when the instruction is executed, it will be called directly and will not be parsed by shell
# ENTRYPOINT ["/ bin/echo", "Hello, $EVN_SET_TEST"]
# the correct way to write it should be:
# ENTRYPOINT ["/ bin/sh", "- c", "echo Hello, $EVN_SET_TEST"]
# pass parameters to ENTRYPOINT in Exec format, resulting in output Hello, $EVN_SET_TEST dockerfile world
# CMD ["dockerfile world"]
# only the last one takes effect
ENTRYPOINT ["java", "- jar", "/ app/app.jar"]
# indicates which port provides the service. If the host wants to access it, it needs to be used in conjunction with the-P parameter.
EXPOSE 8080
3. Maven command
Build image: mvn clean package dockerfile:build-DskipTests
Publish image will not compile: mvn dockerfile:push
Compilation and release: mvn clean install-Ddockerfile.skip
Command description
Dockerfile.skip Disables the entire dockerfile plugin; all goals become no-ops.
Dockerfile.build.skip Disables the build goal; it becomes a no-op.
Dockerfile.tag.skip Disables the tag goal; it becomes a no-op.
Dockerfile.push.skip Disables the push goal; it becomes a no-op.
Thank you for your reading, the above is the content of "how to write docker file files", after the study of this article, I believe you have a deeper understanding of how to prepare docker file files, and the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.