默认Docker入口点 [英] Default Docker entrypoint

查看:114
本文介绍了默认Docker入口点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从另一个设置了特定入口点的图像中创建一个图像。但是我希望我的图像具有默认图像。如何重置ENTRYPOINT?

I am creating an image from another image that set a specific entrypoint. However I want my image to have default one. How do I reset the ENTRYPOINT?

我尝试了以下Dockerfile:

I tried the following Dockerfile:

FROM some-image
ENTRYPOINT ["/bin/sh", "-c"]

不幸的是,它不像默认入口点那样工作,因为它需要用引号引起来。

Unfortunately it doesn't work like the default entrypoint as it need the command to be quoted.

docker run myimage ls -l /    # "-l /" arguments are ignored
file1 file2 file3             # files in current working directory

docker run myimage "ls -l /"  # works correctly

如何使用不带引号的命令?

How do I use commands without quoting?

推荐答案

要禁用现有的 ENTRYPOINT ,请在您的docker文件中设置一个空数组

To disable an existing ENTRYPOINT, set an empty array in your docker file

ENTRYPOINT []

然后您对的论点docker run 将正常执行。

Then your arguments to docker run will exec as normal.

您的 ENTRYPOINT [ / bin / sh, -c] 需要带引号的字符串的原因是,如果没有引号,则将 ls 的参数传递给 sh

The reason your ENTRYPOINT ["/bin/sh", "-c"] requires quoted strings is that without the quotes, the arguments to ls are being passed to sh instead.

不加引号导致许多参数发送到 sh

Unquoted results in lots of arguments being sent to sh

"/bin/sh", "-c", "ls", "-l", "/"

引用允许完整的命令( sh -c )作为一个传递给 sh

Quoting allows the complete command (sh -c) to be passed on to sh as one argument.

"/bin/sh", "-c", "ls -l /"

这篇关于默认Docker入口点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆