Write a example docker file with 2 CMD, 2 ENTRYPOINT

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now
FROM ubuntu
MAINTAINER Raju << raju.shankar@quest-global.com>>
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get -y install tzdata
RUN apt-get update && apt-get install git -y && apt-get install -yq apache2
CMD echo "Hello world from first cmd"
CMD echo "Hello world from second cmd"
ENTRYPOINT ["/bin/echo","HEllo from first entrypoint"]
ENTRYPOINT ["/bin/echo","HEllo from second entrypoint"]

Test1:

docker run 27d064e1c81a
HEllo from second entrypoint /bin/sh -c echo “Hello world from second cmd”

Test2:

root@ip-172-31-28-155:/home/ubuntu/raju# docker run 27d064e1c81a echo test
HEllo from second entrypoint echo test

Explanation:

Only the second cmd or entrypoint is being considered. Moreover if we try to replace cmd during run time then second entrypoint and run time cmd is considered.