Ruby and Rails insider docker



我有一个Ruby on Rails应用程序,正在运行与docker构建。我运行docker-compose builddocker-compose up命令没有问题。它旋转图像并按预期运行puma。

安装的宝石只有rails 6.1.5.1puma 5.6.4

以下是docker-compose up的输出:
my_app   | ENVIRONMENT: development
my_app   | The Gemfile's dependencies are satisfied
my_app   | => Booting Puma
my_app   | => Rails 6.1.5.1 application starting in development
my_app   | => Run `bin/rails server --help` for more startup options
my_app   | Puma starting in single mode...
my_app   | * Puma version: 5.6.4 (ruby 3.0.4-p208) ("Birdie's Version")
my_app   | *  Min threads: 5
my_app   | *  Max threads: 5
my_app   | *  Environment: development
my_app   | *          PID: 9
my_app   | * Listening on http://0.0.0.0:3000
my_app   | Use Ctrl-C to stop

但是,如果我运行以下命令:

docker-compose run --rm my_app rails db:drop db:create db:migrate;

我得到以下错误:

ENVIRONMENT: development
The Gemfile's dependencies are satisfied
Could not find rails-6.1.5.1 in any of the sources
Run `bundle install` to install missing gems.

如果我运行:

docker-compose run --rm my_app sh

它让我看到一个shell提示符。从这个提示符中,我输入rails --version,它返回Rails 6.1.5.1的正确版本。如果我运行rails db:drop,我得到以下内容:

Could not find rails-6.1.5.1 in any of the sources
Run `bundle install` to install missing gems.

如果我运行gem list rails,它显示了正确版本的rails库列表:

rails (6.1.5.1)
sprockets-rails (3.4.2)

有人遇到过这样的问题吗?

你可以试试这个吗:

  1. 以本地方式在pc上安装相应的ruby版本(不带docker)
  2. 运行bundle install这将更新你的Gemfile.lock
  3. 尝试通过运行docker-compose build --no-cache重新构建您的映像

相关内容

  • 没有找到相关文章

最新更新