Dockerfile commands

Here's a markdown table with Dockerfile commands and explanations for each of them:

Dockerfile Command Explanation
FROM Specifies the base image on which the Docker image will be built. It sets the starting point for the Dockerfile and indicates the parent image from the Docker Hub or a custom registry.
MAINTAINER (Deprecated) Used to specify the name and email address of the image maintainer. It is better to use the LABEL command instead to provide metadata about the image.
LABEL Adds metadata to the image. It typically includes information such as the image version, maintainer details, and any other relevant information.
RUN Executes a shell command inside the Docker image. It is used to install packages, configure the environment, and perform other setup tasks during the image build process.
CMD Specifies the default command that should be executed when the Docker container starts. It is typically used for defining the primary application to run in the container. Note that only the last CMD instruction in the Dockerfile will take effect.
EXPOSE Informs Docker that the container will listen on the specified network ports at runtime. However, it does not actually publish the ports to the host by default. This command is used as documentation for the exposed ports.
ENV Sets environment variables inside the Docker image. It allows you to configure the environment for the application running in the container.
ADD Copies files, directories, or remote URLs into the Docker image. It can also extract compressed files and tarballs into the container. Note that the COPY command is preferred over ADD for copying local files.
COPY Copies files or directories from the build context (the current directory) into the Docker image. It is similar to the ADD command, but without the extra features like URL and compressed file support.
ENTRYPOINT Specifies the command that will be executed when the Docker container starts. Unlike CMD, the ENTRYPOINT command cannot be overridden with command-line arguments during container runtime. It is often used for defining the entry point of the application and accepting additional arguments through CMD.
VOLUME Creates a mount point with specified directory path for external volumes. It is used to enable data persistence and sharing between the host and the container or between containers.
USER Sets the user name or UID (User Identifier) to use when running the commands inside the Docker container. This helps enhance security by limiting the privilege level of the executed commands.
WORKDIR Sets the working directory inside the Docker container. It is used to define the directory path where subsequent commands will be executed.
ARG Defines build-time arguments that can be passed during the image build process using the --build-arg flag with the docker build command. These arguments can be used to customize the build process.
ONBUILD Specifies a command or instructions that will be executed when the image is used as a base for another image. It allows you to trigger actions automatically in the derived images. However, it is not commonly used anymore.

Remember, the order of commands in the Dockerfile matters, and some commands, like FROM and RUN, are essential for creating a functioning Docker image, while others might be optional depending on your use case.