DEV Community

Cover image for Docker CMD and ENTRYPOINT and Kubernetes args and command
Ahmed Khaled
Ahmed Khaled

Posted on

Docker CMD and ENTRYPOINT and Kubernetes args and command

Docker

Without passing any commands to docker run both do the same job. However, when docer run is used CMD is replaced if an argument was provided to docker run while ENTRYPOINT will append the arguments to the value defined in the entry point.

You can use both inside the Dockerfile as the parameters of CMD will be appended to ENTRYPOINT.

CMD

# docker run ubuntu-sleep sleep 10

FROM ubuntu

CMD sleep
Enter fullscreen mode Exit fullscreen mode

ENTRYPOINT

# docker run ubuntu-sleep 10

FROM ubuntu

ENTRYPOINT ["sleep"]
Enter fullscreen mode Exit fullscreen mode

Kubernetes

It's dead simple, args in equivalent to CMD and command is equivalent to ENTRYPOINT

Top comments (0)