Docker Cheat sheet Series : Docker File

Part 3

pradeep padmarajaiah
1 min readMay 22, 2018

FROM : Defines the base image from which,new image will be created

FROM ubuntu
FROM openjdk:8-jdk-alpine

RUN : Will execute any valid Linux command

RUN apt-get update
RUN apt-get install –y curl

RUN mkdir -p /tmp/pradeep/test
RUN chmod 777 /tmp/pradeep/test

COPY : Copies the files and folders from host to docker image

COPY . /tmp/pradeep/test

ADD : Works as COPY. Also , has capability to untar the file and copy the file URL

ADD sample.tar /tmp/pradeep/test
ADD https://www.w3.org/TR/PNG/iso_8859-1.txt /tmp/pradeep/test

WORKDIR : Changes the mentioned directory as the present working directory for the image going forward . Note : RUN cd dir will execute as a command ,but it will not have effect change directory while create the image

WORKDIR /tmp/pradeep/test
ADD https://www.w3.org/TR/PNG/iso_8859-1.txt download.txt

CMD & ENTRYPOINT : It is the first process or task when container is started. It can be overridden by passing arguments when running the container. NOTE: If ENTRYPOINT is undefined, docker will have default value as “/bin/sh -c” and executes the “CMD” command as /bin/sh -c “ls -lrt /tmp/pradeep/test

CMD [“ls”,”-lrt”,”/tmp/pradeep/test”]
OR
ENTRYPOINT [“ls”]
CMD [“-lrt”,”/tmp/pradeep/test”]
OR
CMD ls -lrt /tmp/pradeep/test

MAINTAINER : Metadata information. Name or emailid of the maintainer for the DockerFilw

--

--