docker:在 $PATH 中找不到可执行文件 [英] docker: executable file not found in $PATH

查看:55
本文介绍了docker:在 $PATH 中找不到可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装 grunt 的 docker 镜像,但是当我尝试运行它时,出现错误:

I have a docker image which installs grunt, but when I try to run it, I get an error:

Error response from daemon: Cannot start container foo_1: 
    exec: "grunt serve": executable file not found in $PATH

如果我在交互模式下运行 bash,grunt 可用.

If I run bash in interactive mode, grunt is available.

我做错了什么?

这是我的 Dockerfile:

Here is my Dockerfile:

# https://registry.hub.docker.com/u/dockerfile/nodejs/ (builds on ubuntu:14.04)
FROM dockerfile/nodejs

MAINTAINER My Name, me@email.com

ENV HOME /home/web
WORKDIR /home/web/site

RUN useradd web -d /home/web -s /bin/bash -m

RUN npm install -g grunt-cli
RUN npm install -g bower

RUN chown -R web:web /home/web
USER web

RUN git clone https://github.com/repo/site /home/web/site

RUN npm install
RUN bower install --config.interactive=false --allow-root

ENV NODE_ENV development

# Port 9000 for server
# Port 35729 for livereload
EXPOSE 9000 35729
CMD ["grunt"]

推荐答案

当你使用 exec 格式的命令(例如 CMD ["grunt"],一个带双引号的 JSON 数组)它将在 没有 shell 的情况下执行.这意味着大多数环境变量将不存在.

When you use the exec format for a command (e.g. CMD ["grunt"], a JSON array with double quotes) it will be executed without a shell. This means that most environment variables will not be present.

如果您将命令指定为常规字符串(例如 CMD grunt),则 CMD 之后的字符串将使用 /bin/sh -c.

If you specify your command as a regular string (e.g. CMD grunt) then the string after CMD will be executed with /bin/sh -c.

Dockerfile 参考的 CMD 部分中提供了更多信息一>.

More info on this is available in the CMD section of the Dockerfile reference.

这篇关于docker:在 $PATH 中找不到可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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