Sobes.tech
Junior — Middle

What instructions are used in Dockerfile to build your project image?

sobes.tech AI

Answer from AI

In a Dockerfile for building a project image, the following main instructions are usually used:

  • FROM — specifies the base image from which the new image will be built.
  • WORKDIR — sets the working directory inside the container.
  • COPY or ADD — copy files and directories from the build context into the image.
  • RUN — executes commands inside the image during the build (e.g., installing dependencies).
  • ENV — sets environment variables.
  • EXPOSE — declares the ports that the container will listen on.
  • CMD or ENTRYPOINT — specify the command that will be executed when the container starts.

Example of a simple Dockerfile for a Java application:

FROM openjdk:17-jdk-slim
WORKDIR /app
COPY target/myapp.jar ./
CMD ["java", "-jar", "myapp.jar"]
What instructions are used in Dockerfile to build… - sobes.tech