Understanding Commonly used DockerFile statements
In this Exercise we will understand the use of commonly referred commands in Docker file for containerizing a Node js application. Lets take an example of a docker file as given below:
Docker File Keywords
- FROM <Image Name>:<Image Version>
This represents the base image to be used for the container, this depends on the type of application we are containerizing in this case its node because we are trying to containerize Node application.
- ENV <Environment Identifier> = <Environment Name>
This statement sets the Environment needed for running the application.
- WORKDIR <Working directory name>
- COPY <List of files>
- RUN <Command>
- EXPOSE <port number>
- USER <user name>
This statement is used to define the user which will be used for running the application. Default user will be the user of the parent or the base image.
- CMD <Command>
This statement is used to start the application which is being containerized, This statement gets executed while the container starts. Unlike the RUN command which gets executed inside the docker image while the daemon tries to build the Docker image. In our case its node <start file name> since its a Node js application server.
Suggested Read : Containerizing Application using Docker
Comments
Post a Comment