One what is Dockerfile :
A Dockerfile is a script consisting of a series of commands and parameters that are applied to the base image and ultimately create a new image . They simplify the start-to-finish process and greatly simplify deployment. A Dockerfile starts with the FROM command , followed by various methods, commands, and parameters. The output is a new image that can be used to create containers.
Two dockerfile of a simple Play Framework project
FROM openjdk:8-jre-alpine ARG PACKAGE="projectName-1.0.0-SNAPSHOT-dist.zip" COPY target/${PACKAGE} /${PACKAGE} RUN mkdir /build && \ unzip /${PACKAGE} -d /build EXPOSE 9000 ENTRYPOINT ["java", "-Dhttp.address=0.0.0.0", "-Dhttp.port=9000", "-cp", "/build/*", "play.core.server.ProdServerStart"]
FROM: Specify the base image, the base image must be specified. And FROM is to specify the base image, so FROM in a Dockerfile is a necessary instruction and must be the first instruction
ARG build parameters: Set environment variables. The difference is that the environment variables of the build environment set by ARG will not exist when the container runs in the future.
expose : exposes the port, but does not map to the host and is only accessible by connected services. Only internal ports can be specified as parameters.
ENTRYPOINT : Specify the container launcher and parameters
Three: Use the docker build command to generate the dockers image
docker build -t imagename . (note the dot after it)