我创建了一个简单的Dockerfile来全局安装一些节点工具。
FROM node:10.9.0
RUN npm -g config set user root
RUN npm -g install --unsafe-perm merge-yaml
RUN mkdir -p /workDirectory
WORKDIR /workDirectory
构建图像,我希望可以在任何路径上(全球)使用merge-yaml
docker build -t thisisme/devtools .
但是使用exec找不到命令
docker run --rm -it -v ${PWD}:/workDirectory thisisme/devtools merge-yaml
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"merge-yaml\": executable file not found in $PATH".
如果我进入容器并确认模块未全局添加:
docker run --rm -it thisisme/devtools /bin/bash
root@e77027bb2f57:/workDirectory# merge-yaml
bash: merge-yaml: command not found
我确定我做错了,因为在交互模式下,全局安装并无法正常工作(如我预期的那样)
root@e77027bb2f57:/workDirectory# npm install -g merge-yaml
+ merge-yaml@1.1.0
updated 1 package in 0.584s
root@e77027bb2f57:/workDirectory# merge-yaml
bash: merge-yaml: command not found
root@e77027bb2f57:/workDirectory#
预先感谢
答案 0 :(得分:4)
如果要使用命令行,则应改为安装Controller
。
Dockerfile:
merge-yaml-cli
构建图像后,可以使用merge-yaml:
FROM node:10.9.0
RUN npm -g config set user root
RUN npm -g install --unsafe-perm merge-yaml-cli
RUN mkdir -p /workDirectory
WORKDIR /workDirectory