【发布时间】:2021-03-11 22:44:33
【问题描述】:
Deployment 看不到配置文件的原因是什么?
这是部署的一部分
command: ["bundle", "exec", "puma", "-C", "config/puma.rb"]
already tried with ./config/.. and using args instead of command
我收到Errno::ENOENT: No such file or directory @ rb_sysopen - config/puma.rb
过去在 docker-compose 上一切正常
当我保留下面 Dockerfile 中的最后一行 (CMD) 并在 Deployment 中省略 command: 时,一切正常 但是,要为 sidekiq 重用图像,我需要提供配置文件.
Dockerfile
FROM ruby:2.7.2
RUN apt-get update -qq && apt-get install -y build-essential ca-certificates libpq-dev nodejs postgresql-client yarn vim -y
ENV APP_ROOT /var/www/app
RUN mkdir -p $APP_ROOT
WORKDIR $APP_ROOT
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
COPY public public/
RUN gem install bundler
RUN bundle install
# tried this
COPY config config/
COPY . .
EXPOSE 9292
# used to have this line but I want to reuse the image
# CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
错误信息
bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
Errno::ENOENT: No such file or directory @ rb_sysopen - config/puma.rb
更新
问题似乎与错误的路径和对命令和参数字段的误解有关。以下配置对我有用。 docker也可能存在缓存问题(之前发生在我身上)
command:
- bundle
- exec
- puma
args:
- "-C"
- "config/puma.rb"
【问题讨论】:
-
试试
COPY config $APP_ROOT/config/ -
我认为使用
WORKDIR和COPY . .已经复制了这个文件夹 -
当我在 Deployment 中不使用
command并且我将 CMD 保留在 dockerfile 的底部时,此图像工作正常。它也适用于docker-compose(但我在那里使用context: build)这不是在dockerfile中复制的问题 -
您的部署规范中是否有任何
volumeMounts:或其他任何会更改容器文件系统的内容?应该没什么区别,但是将command:更改为args:有帮助吗? (Kubernetescommand:与 DockerENTRYPOINT匹配,args:与CMD匹配,令人困惑;但您显示的内容没有ENTRYPOINT。) -
@kirqe 您能否详细说明您的解决方案并将其作为答案发布?它可能会帮助其他社区成员。
标签: ruby-on-rails docker kubernetes sinatra