【问题标题】:/bin/sh: service: command not found on cent os 7/bin/sh: service: 在 centos 7 上找不到命令
【发布时间】:2019-03-02 17:46:04
【问题描述】:

在 Dockerfile 中构建此命令时:

RUN service start newrelic-infra

我收到此错误:

/bin/sh: service: command not found 命令'/bin/sh -c service start newrelic-infra' 返回一个非零代码:127

在Dockerfile中插入这个yum -y install initscripts && yum clean all并执行RUN service start newrelic-infra之后, 我遇到了同样的错误。

【问题讨论】:

  • 您应该假设像 servicesystemctl 这样的命令在 Docker 中不起作用。即使RUN service start 没有引发错误,运行进程的事实也不会保留在映像中;下一个RUN 命令和任何最终的docker run 都不会运行该进程。
  • @DavidMaze,你能解释一下这是为什么吗?

标签: docker centos dockerfile newrelic


【解决方案1】:

您可能需要使用以下内容:

RUN yum update -y && yum install initscripts -y

至少这对我有用。 此外,还有一个 Github 问题,其中包含可能有帮助的更多信息: https://github.com/CentOS/sig-cloud-instance-images/issues/28

【讨论】:

    猜你喜欢
    • 2022-08-09
    • 2021-11-13
    • 2019-04-19
    • 2013-05-16
    • 2018-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多