What is Dockerfile | How to create and build Dockerfile | Dockerfile Basic Commands

preview_player
Показать описание
This video explains the keyword used in a Dockerfile.
main parameters used:

1. FROM: Mandatory parameter to specify base image reference.

2. MAINTAINER: Optional, an author who created file.

3. RUN: Command you want to execute to provision image: you can use && to run multiple commands by single RUN command.

When you use a RUN command in your docker file, it always creates a new intermediate image layer on top of the previous ones. That’s why it is always recommended to chain all the RUN commands together.

RUN command in executable form is:

RUN ["apt-get", "install", "firefox"]

like RUN Command1 && Command2 && Command3 (one single RUN command will make only 1 commit)

4. ADD: you want to copy some file into the image from the internet.

5. COPY: Same as ADD, but copy can copy only local files like from docker host.

6. EXPOSE: To specify on which port container application will run.

7. WORKDIR: to change the current working folder (like cd)

8. USER: user who will be owning container namespace process. like when you will log in to the container then do whoami , you will see your user.
for security purposes, it should not be root. this user should exist in the base image or should be created before using it.

9. ENV: to declare variable while writing image, like ENV port 8080 AND then we can use EXPOSE $port
Рекомендации по теме