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

DevOps

MOTOSHARE 🚗🏍️
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
🚀 Everyone wins.

Start Your Journey with Motoshare

Dockerfile with 2 CMD, 2 ENTRYPOINT:

File content:

FROM ubuntu
MAINTAINER Sunil << r.s.sunil@gmail.com>>
CMD "World" 
CMD echo "DOCKER"
ENTRYPOINT ["/bin/echo", "Hello"]
ENTRYPOINT ["/bin/echo", "Welcome to"]Code language: CSS (css)

Output:

Welcome to /bin/sh -c echo “DOCKER”

Observations:

  • Both CMD and ENTRYPOINT entries will be overwritten with the latest entries.
  • That is only the last CMD and ENTRYPOINT will be taken.
  • Also the values specified in CMD will be add as an argument to the ENTRYPOINT command.

Dockerfile with 1 CMD, 1 ENTRYPOINT:

File content:

FROM ubuntu
MAINTAINER Sunil << r.s.sunil@gmail.com>>
CMD "World" 
ENTRYPOINT ["/bin/echo", "Hello "]Code language: CSS (css)

Output:

Hello World

Observations:

  • Values specified in CMD will be add as an argument to the ENTRYPOINT command.