近來需要在服務(wù)器上起一個c++編譯后的socket服務(wù)蚊伞,
RUN 在docker里是用來生成鏡像的
在使用
RUN ./server
后瞻佛,因為服務(wù)一致開啟所以卡住了咖熟,無法生成鏡像;
CMD [./server]
生成了鏡像击纬,但是在一段時間后自動推出,不知道為什么钾麸;
ENTRYPOINT [./server]
可以正常使用了更振,在開始容器后可以正常對外提供服務(wù)炕桨;
在網(wǎng)上查了一下他們的區(qū)別:
Use RUN instructions to build your image by adding layers on top of initial image.
Prefer ENTRYPOINT to CMD when building executable Docker image and you need a command always to be executed. Additionally use CMD if you need to provide extra default arguments that could be overwritten from command line when docker container runs.
Choose CMD if you need to provide a default command and/or arguments that can be overwritten from command line when docker container runs.
轉(zhuǎn)自:http://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/