Question-26: What is the use of Dickerfile?
Answer: A Dockerfile can be used to automate the creation or building of a Docker container image.
Question-27: What is .dockerignore file?
Answer: This .dockerigonre defines the set of files that should be ignored when copying files into the image.
Question-28: Which are the two main files when you create a Docker Image?
Answer: There are following two files which is required when you what to create Docker Container
- Dockerfile: You can say this a recipe to create a Docker Container.
- .dockerignore: This would define what all files to be ignored while copying file to container.
Question-29: As you know, every Docker image is built on another Docker image, which attriubute in Dockerfile you use for base container?
Answer: “FROM” attribute. Example as below
FROM node:11
Here, it is specifying that get the preconfigured container from Docker Hub which has Node.js 11 already installed.
Question-30: Can you please explain the few main attributes of Dockerfile?
Answer: Below are the main attributes in the Dockerfile, which you come across many times
- WORKDIR: You can specify the directory inside the container image, where all the command would run.
- COPY: Copy the files.
- RUN: Run the command in the container.
- CMD: This specify the default command when you start the container.
- FROM: What should be the base image for a container.