Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Docker ENTRYPOINT and Kubernetes container spec COMMAND?

Dockerfile has a parameter for ENTRYPOINT and while writing Kubernetes deployment YAML file, there is a parameter in Container spec for COMMAND.

I am not able to figure out what's the difference and how each is used?

like image 883
tusharfloyd Avatar asked Jun 01 '17 20:06

tusharfloyd


People also ask

Does Kubernetes use Docker ENTRYPOINT?

Kubernetes allows you to override both the image's default command (docker Entrypoint ) and args (docker Cmd ) with the Command and Args fields of Container .

Does Kubernetes command override ENTRYPOINT?

Overriding ENTRYPOINT and CMD in KubernetesYou can also override either ENTRYPOINT Or CMD Or Both when running container in Kubernetes. However Kubernetes manifest files use different spec names as compared to Dockerfile. This is useful table from Kubernetes Documentation.

What is the difference between command and ENTRYPOINT in Docker?

The ENTRYPOINT instruction looks almost similar to the CMD instruction. However, the main highlighting difference between them is that it will not ignore any of the parameters that you have specified in the Docker run command (CLI parameters).

What is the difference between Kubernetes and Dockers?

The difference between the two is that Docker is about packaging containerized applications on a single node and Kubernetes is meant to run them across a cluster.


1 Answers

Kubernetes provides us with multiple options on how to use these commands:

When you override the default Entrypoint and Cmd in Kubernetes .yaml file, these rules apply:

  • If you do not supply command or args for a Container, the defaults defined in the Docker image are used.
  • If you supply only args for a Container, the default Entrypoint defined in the Docker image is run with the args that you supplied.
  • If you supply a command for a Container, only the supplied command is used. The default EntryPoint and the default Cmd defined in the Docker image are ignored. Your command is run with the args supplied (or no args if none supplied).

Here is an example:

Dockerfile:

FROM alpine:latest COPY "executable_file" / ENTRYPOINT [ "./executable_file" ] 

Kubernetes yaml file:

 spec:     containers:       - name: container_name         image: image_name         args: ["arg1", "arg2", "arg3"] 

https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/

like image 191
Berk Soysal Avatar answered Oct 11 '22 05:10

Berk Soysal