ruby-on-rails - 为什么 docker run 有效,但同一图像的 docker-compose 无效?
问题描述
我尝试rails new testapp
使用 docker 运行应用程序。
当我运行它时run -dp 3000:3000 -v "$(pwd):/app" testapp
它工作正常,但是当我尝试运行它时,docker-compose up
我得到:
web_1 | Could not locate Gemfile or .bundle/ directory
testapp_web_1 exited with code 10
知道为什么吗?
Dockerfile:
FROM ruby:2.7.2
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN bundle install
COPY . .
CMD ["rails", "server", "-b", "0.0.0.0"]
码头工人-compose.yml:
version: "3.8"
services:
web:
build: .
volumes:
- ./app:/app
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
ports:
- 3000:3000
解决方案
推荐阅读
- r - 在闪亮的应用程序中调整嵌入图像的大小
- mysql - 改成utf8mb4后查询速度变慢
- angular - 检测宿主项目中角度库的变化
- css - 现有背景图像上的渐变背景图像
- c - Does the -O0 compiler flag have the same effect as the volatile keyword in C?
- angular - Ionic 3 和 Ngzone 不工作 - 不将结果更新到 HTML 视图
- kubernetes - 如何仅更新容器?
- reactjs - 无法在reactjs jsx中自动完成标签
- python - python调试器:不以交互方式初始化变量
- c++11 - 我初始化 char *str1 = nullptr 并输出到屏幕...但是当我想输出到其他变量时,我收到空屏幕..为什么会这样?