====== Dockerfile ====== Unos apuntes: 1/ A Dockerfile is a text file that contains instructions for building a Docker image. 2/ The first line of a Dockerfile specifies the base image to use. For example, "FROM node:12-alpine" specifies that the image should be based on the Node.js 12 Alpine Linux image. 3/ The "WORKDIR" instruction sets the working directory for any subsequent instructions. For example, "WORKDIR /app" sets the working directory to "/app". 4/ The "COPY" instruction copies files from the host machine to the image. For example, "COPY package.json /app" copies the package.json file from the host machine to the "/app" directory in the image. 5/ The "RUN" instruction runs a command inside the image. For example, "RUN npm install" runs the "npm install" command inside the image. 6/ The "EXPOSE" instruction exposes a port from the container to the host machine. For example, "EXPOSE 3000" exposes port 3000 from the container to the host machine. "EXPOSE" instruction can also specify the protocol to use, such as "EXPOSE 8080/tcp". 7/ The "CMD" instruction specifies the default command to run when the container starts. For example, "CMD npm start" specifies that the "npm start" command should be run by default. 8/ 1/ "ENV" instruction sets environment variables in the image. For example, "ENV NODE_ENV=production" sets the NODE_ENV environment variable to "production" in the image. 9/ "ARG" instruction sets build-time variables. For example, "ARG VERSION=1.0.0" sets the VERSION build-time variable to "1.0.0". 10/ "USER" instruction sets the user ID or username to use when running the container. For example, "USER node" sets the user to "node". 11/ "VOLUME" instruction creates a mount point for a named or anonymous volume. For example, "VOLUME /data" creates a mount point at "/data". 12/ "ADD" instruction copies files from the host machine to the image and can also extract tar files. For example, "ADD app.tar.gz /app" extracts the app.tar.gz file and copies its contents to the "/app" directory in the image. 12/ "ADD" instruction copies files from the host machine to the image and can also extract tar files. For example, "ADD app.tar.gz /app" extracts the app.tar.gz file and copies its contents to the "/app" directory in the image. 13/ "LABEL" instruction adds metadata to the image. For example, "LABEL version=1.0" adds a "version" label with a value of "1.0" to the image. Example: Let's say we want to create a Dockerfile for a Node.js web application. Here's an example Dockerfile: FROM node:12-alpine WORKDIR /app COPY package.json . RUN npm install COPY . . EXPOSE 3000 CMD ["npm", "start"] Explanation - In this example, we're using the Node.js 12 Alpine Linux image as the base image. We set the working directory to "/app" and copy the package.json file to the working directory. Then we run "npm install" to install the dependencies. Next, we copy the rest of the files in the current directory to the "/app" directory in the image. We expose port 3000 and set the default command to "npm start". Overall, this Dockerfile provides a reproducible, consistent environment for running our Node.js web application in a containerized environment.