CMD is nothing but an argument to the EntryPoint by default docker uses “/bin/sh -c” as an entry point. So if we are defining only CMD in docker file it uses “/bin/sh -c” for example,
If Dockerfile will having below format,
CMD [“bash”]
Default command which docker container will run, will be “/bin/sh -c bash”
If Dockerfile will having below format,
CMD [“ping 8.8.8.8 -c 4”]
Default command which docker container will run, will be “/bin/sh -c ping 8.8.8.8 -c 4”
If Dockerfile will having below format,
ENTRYPOINT [“/bin/ping”]
CMD [“ 8.8.8.8 -c4”]
Default command which docker container will run, will be “/bin/ping 8.8.8.8 -c 4”
If Dockerfile will having below format,
ENTRYPOINT [“/bin/ping”,”-c”,”4”]
CMD [“8.8.8.8”]
Default command which docker container will run, will be “/bin/ping -c 4 8.8.8.8”