Dockerfile


This post serves as a quick note on how to create a Dockerfile. It is not intended to be a comprehensive guide for the same.

1) FROM = The image from dockerhub on which the current image should be based on 

2) MAINTAINER = This is just a free text field where you put in your Name or email id, just so that people can identify the maintainer 

3) EXPOSE= The port on which the container should be exposed. This can be overridden while doing a docker run command. 

4) ENTRYPOINT= The command to be executed when the container strats up. 
For Example: npm start 

5) COPY = used to copy the source code into the docker machine. 
For exmple: COPY . /var/www 
Where .(dot) represents that the whole of current directory needs to be copied. 


6) WORKDIR = The root directory from where the commands need to be run. For example, while running npm start, the directory in the container from where it should be run. 

7) RUN = A command that the container has to run 

8) VOLUME = The location where the volume should be mounted on the remote container 


9) ENV= This can be used to set environment variables for the container.  

For example: 
ENV PORT = 3000 
If the environment variables need to be used in the docker file, it can be used as follows: 
For example: 
EXPOSE $PORT 




Comments

Popular posts from this blog

Docker Commands

ES-6 classes