The difference between entrypoint and cmd
The difference between entrypoint and CMD can refer to the difference between entrypoint and cmd in Dockerfile
The main differences are:
If you use the command-line arguments when you start the container with Docker run, the CMD directive in Dockerfile will be invalid:
Docker run-it Image/bin/ps
After the boot container is found to have no shell, only the process state in the current container is printed out, and the cmd command effect is overwritten:
PID TTY Time CMD
1? 00:00:00 PS
[Root@miwifi-r3l-srv test]#
What to do if you want to pass command-line arguments when you start the container with Docker run. This is the uniqueness of entrypoint.
The command specified by entrypoint needs to be paired with the Docker run boot container, using the contents of the Docker run instruction as parameters to run the command as specified by the entrypoint instruction EntryPoint The specified Linux command is generally not overwritten. the role of Run
The role of run is that sometimes you need to install some software on the underlying image, such as Nginx, when building the image. For example:
From CentOS
Maintainer Allocator
RUN Yum install-y nginx
RUN Echo ' Hello World ' >/usr/share/nginx/html/index.html
EXPOSE 80
entrypoint ["/usr/sbin/nginx"]
The two run above installs the Nginx and writes content to the index.html when the image is built.