Docker cmd and entrypoint
Docker - container only exist if the service alive
Example: ubuntu
If run docker run ubuntu and check docker ps -a, you find it stopped.
The reason is the CMD is only bash
To make it live create another dockerfile ubuntu-sleeper
FROM Ubuntu
CMD sleep 5
#docker build -t ubuntu-sleeper .
#docker run ubuntu-sleeper
If you want to change sleep time, you need to run
#docker run ubuntu-sleeper sleep 10
If want to remove sleep in command, you need to change to use ENTRYPOINT
FROM Ubuntu
ENTRYPOINT ["sleep"]
#docker build -t ubuntu-sleeper
#docker run ubuntu-sleeper 10
If you want to setup default value of sleep
FROM Ubuntu
ENTRYPOINT ["sleep"]
CMD ["5"]
Comments
Post a Comment