Dockerfile — CMD Vs ENTRYPOINT

Shell and Exec Form

<instruction> <command>
<instruction> ["executable", "parameter"]

ENTRYPOINT or CMD

Docker CMD

vi Dockerfile
FROM ubuntu
MAINTAINER Bikram
RUN apt-get update
CMD ["echo", "Hello World"]
$ docker build -t ubuntu-test .
$ docker run -it ubuntu-test:latest
$ docker run -it ubuntu-test:latest echo "Hi!"
FROM ubuntu
MAINTAINER Bikram
RUN apt-get update
CMD ["echo", "Hello Docker"]
CMD ["echo", "Hello Python"]

Docker Entrypoint

FROM ubuntu
MAINTAINER sofija
RUN apt-get update
ENTRYPOINT ["echo", "Hello Google"]
$ docker build -t ubuntu-test .
$ docker run -it ubuntu-test:latest
$ docker run -it ubuntu-test:latest "Hello AWS"

Docker Entrypoint with CMD

$ vi Dockerfile
FROM ubuntu
MAINTAINER Bikram
RUN apt-get update
ENTRYPOINT ["echo", "Hello"]
CMD ["Google World"]
$ docker build -t ubuntu-test .
$ docker run -it ubuntu-test:latest
$ docker run -it ubuntu-test:latest Bikram

Conclusion

Cloud and DevOps Enthusiast