The difference between CMD and ENTRYPOINT
CMD command
- CMD specifies the command to run when the container is started, only the last one will take effect and will be replaced
- Create a dockerfile
FROM centos CMD ["ls","-a"]
- Build image
docker build -f dockerfile-cmd-test -t cmdtest .
- To append a -l command, execute the ls -al command
- In the case of CMD, -l replaced the CMD ["ls","-a"] command, but -l is not a command, so an error was reported .
ENTRYPOINT command
- ENTRYPOINT to operate, create a dockerfile
- Build and run
- As shown in the figure above, until this step, the results are no different from using CMD
- Plus -l test
- You will find that the result is not only correct, but also the same as executing ls -al, so you can see the difference between the two commands
- Here the -l command is directly spliced after the ENTRYPOINT command
(Docker notes): The difference between CMD and ENTRYPOINT
Guess you like
Origin blog.csdn.net/baidu_41388533/article/details/108564993
Ranking