Rails 6 运行 on Docker 安装了 bundler -v 2.0.2...您必须将 Bundler 2 或更高版本与此锁定文件一起使用

Rails 6 running on Docker with bundler -v 2.0.2 installed... You must use Bundler 2 or greater with this lockfile

我正在向 Docker 添加一个新的 Rails 6 / Ruby 2.6 / Postgres 应用程序,但是每当我尝试 运行 rake 命令(例如docker-compose run web rake db:setup) 在容器中,我得到:

You must use Bundler 2 or greater with this lockfile.

我已经尝试在容器中显式安装 Bundler 2.0.2,但是没有成功。

运行 在 Rails 容器内,bundler-v returns 2.0.2,

root@114f7d6a2b72:/app# bundler -v
Bundler version 2.0.2

在Gemfile.lock内:

RUBY VERSION
   ruby 2.6.0p-1

BUNDLED WITH
   2.0.2

并且在 Docker 文件中:

FROM ruby:2.6.0
...more stuff...
COPY Gemfile Gemfile.lock package.json yarn.lock ./
RUN gem install bundler -v 2.0.2
RUN bundle install --verbose --jobs 20 --retry 5

这看起来简单,但我无法让它工作。我错过了什么?

Docs,你必须 运行 gem update --system 升级 bundel 我建议也使用 ruby:2.6.1