Shell格式:指令 <command>
CMD java -jar test.jar
Exec格式:指令 ["executable", "param1", "param2", ...]
ENTRYPOINT ["java", "-jar", "test.jar"]
CMD 指令的命令支持以下三种格式:
ENTRYPOINT 指令的命令支持以下了两种格式:
docker run [image] 参数
后面追加的参数docker run [image] 参数
后面追加的参数ENTRYPOINT的Exec格式
# Dockerfile
FROM centos
ENTRYPOINT ["/bin/echo", "Hello"]
# 启动容器的命令: docker run -it [image]
# 输出: Hello
# 启动容器的命令: docker run -it [image] Test
# 输出: Hello Test
ENTRYPOINT的Exec格式
+ CMD的Exec格式
# Dockerfile
FROM centos
ENTRYPOINT ["/bin/echo", "Hello"]
CMD ["Word"]
# 启动容器的命令: docker run -it [image]
# 输出: Hello Word
# 启动容器的命令: docker run -it [image] Test
# 输出: Hello Test
ENTRYPOINT的Exec格式
+ CMD的shell格式
# Dockerfile
FROM centos
ENTRYPOINT ["/bin/echo", "Hello"]
CMD Word
# 启动容器的命令: docker run -it [image]
# 输出: Hello /bin/sh -c Word
# 启动容器的命令: docker run -it [image] Test
# 输出: Hello Test
ENTRYPOINT的shell格式
# Dockerfile
FROM centos
ENTRYPOINT /bin/echo "Hello"
# 启动容器的命令: docker run -it [image]
# 输出: Hello
# 启动容器的命令: docker run -it [image] Test
# 输出: Hello
ENTRYPOINT的shell格式
+ CMD的Shell格式
# Dockerfile
FROM centos
ENTRYPOINT /bin/echo "Hello"
CMD Word
# 启动容器的命令: docker run -it [image]
# 输出: Hello
# 启动容器的命令: docker run -it [image] Test
# 输出: Hello
ENTRYPOINT的shell格式
+CMD的Exec格式
# Dockerfile
FROM centos
ENTRYPOINT /bin/echo "Hello"
CMD ["Word"]
# 启动容器的命令: docker run -it [image]
# 输出: Hello
# 启动容器的命令: docker run -it [image] Test
# 输出: Hello
https://blog.csdn.net/weixin_42971363/article/details/91506844
原文出处:https://gitbook.curiouser.top/origin/docker-Dockerfile%E4%B8%ADCMD%E4%B8%8EENTRYPOINT%E5%91%BD%E4%BB%A4%E7%9A%84%E5%8C%BA%E5%88%AB.html