docker:$ PATH中找不到可执行文件 [英] docker: executable file not found in $PATH
问题描述
我有一个docker图像安装 grunt
,但是当我尝试运行它时,我收到一个错误:
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参考。
More info on this is available in the CMD section of the Dockerfile reference.
这篇关于docker:$ PATH中找不到可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!