Skip to main content

Command Palette

Search for a command to run...

Dockerfile

Published
2 min readView as Markdown

if dockerfile named is changed we shd use

$ docker build -f dockerfilenmae -t imagename .

-f dockerfile

-t --> it is imagename

  1. FROM: indicates base image to run our application, we can have more than 1 base image

ex:- FROM ubuntu

  1. MAINTAINER - represent who is the author of dockerfile

ex:- MAINTAINER GOVI

  1. COPY - is used to copy files or folders to image while creating image

ex:- COPY <source> <destination>

  1. ADD - is used to copy files to image

ex:- ADD <source> <destination>

add cmd can extract tar file only not zip files

DIFFERENCE BETWEEN COPY AND ADD --> ADD CMD can download files from remote url (its wget in docker file)

  1. RUN - it used to execute cmds only while creating the image

ex:- RUN mkdir workspace

ex:- RUN apt install git -y

  1. CMD - used to exec cmds only while conatiner is created ,

( the cmds is exec when container is started it can only be run once, CMD we can override )

ex:- CMD service start docker

  1. ENTRYPOINT - used to exec cmds only while the container is created, CMD we can override but ENTRYPOINT cant be override( CMD can be override using cmd line arrugument )

ex:- ENTRYPOINT [ "echo",hello world"]

  1. WORKDIR - used to set working DIR of image or container ( the cmds will be executed from WORKDIR directory

ex: WORKDIR <DIR-PATH>

  1. ENV - used to set environment variables

ex: ENV <key> <value>

  1. LABEL - used to represent data in key-value pair

  2. ARG - used to avoid hard-coded values in docker file

    ex:- ARG branch=dev

  3. USER - used to set user for container or images

  4. EXPOSE - used to represent which port number our container is running

More from this blog

dev ops

26 posts