Assignement of Day-2

Q1. List out all INSTRUCTION statement of dockerfile and give one line explanation.
Environment variables are supported by the following list of instructions in the Dockerfile:

ADD -> check if compressed file and copying the content to docker container
COPY -> Just copying the content to docker container
EXTRACT -> Extract the content to specified location in docker container

ENV -> for setting the environment values
EXPOSE -> exporting the port of the application to outside container.

FROM -> pull the docker image
LABEL -> instruction adds metadata to an image

STOPSIGNAL -> instruction sets the system call signal that will be sent to the container to exit
USER -> setting the runtime user
VOLUME -> for mounting shared directories via volumes.

WORKDIR -> sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD

Q2. Build all these 5 images and run container and observe the use cases of it.
https://devopsschool.com/tutorial/docker/dockerfile/dockerfile-example-sample-lab.html

1 -> CMD execute the executable and failed with an error
2 -> Hello world printed using cmd
3 -> Hello printed using entrypoint
4 -> CMD execute the executable and failed with an error and exposed the application port 80
5 -> Printted the first hello in entrypoint and cmd command option printed after that. i.e. “/bin/sh -c echo “Hello world”

root@ip-172-31-28-155:~/abhin# docker run abhin_555
Hello /bin/sh -c echo “Hello world”

Q3. Write a example dockerfile with 2 CMD, 2 ENTRYPOINT and 1 CMD/1ENTRYPOINT and write down a behaviour of it.

-> Here the last entrypoint was executed and last CMD command option was printed.

CMD echo “Hello world cmd-1”
CMD echo “Hello world cmd-2”
ENTRYPOINT [“/bin/echo”, “Hello-entry-1”]
ENTRYPOINT [“/bin/echo”, “Hello-entry-2”]

root@ip-172-31-28-155:~/abhin# docker run abhin_6
Hello-entry-2 /bin/sh -c echo “Hello world cmd-2”

-> entrypoint will be executed first

ENTRYPOINT [“/bin/echo”, “Hello-entry-1”]
CMD echo “Hello world cmd-1”

root@ip-172-31-28-155:~/abhin# docker run abhin_7
Hello-entry-1 /bin/sh -c echo “Hello world cmd-1”