我有bash文件,该文件可构建gem文件并启动程序:

cd /src/stackify-api
rm *.gem
gem build stackify.gemspec
gem install stackify-0.1.0.gem

cd /src/stackify-classificator
rm *.gem
gem build stackify-classificator.gemspec
gem install stackify-classificator-0.1.1.gem

cd /src/bin
ruby console-task.rb

我在docker容器中使用它。如果我以交互方式启动容器并手动运行此bash文件,则效果很好:
 ~ » docker run -it -v /mnt/lacie/online/btsync/development:/src stack_rvm /bin/bash
root@898cec6a7d85:/# /src/build.sh
  ...
  Successfully built RubyGem
  Name: stackify
  Version: 0.1.0
  File: stackify-0.1.0.gem

但是,当我尝试像这样在docker中启动此脚本时,出现错误消息:
 ~ » docker run -it -v /mnt/lacie/online/btsync/development:/src stack_rvm /bin/bash /src/build.sh
/src/build.sh: line 5: gem: command not found

为什么以及如何解决?

最佳答案

我找到了答案-使用-c -l:

~ » docker run -it -v /mnt/lacie/online/btsync/development:/src stack_rvm /bin/bash -c -l /src/build.sh

关于ruby - gem:找不到命令,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29998746/

10-16 23:48