【问题标题】:Docker Compose on Windows 7: Could not locate Gemfile or .bundle/ directoryWindows 7 上的 Docker Compose:找不到 Gemfile 或 .bundle/ 目录
【发布时间】:2016-08-18 12:48:02
【问题描述】:

运行命令docker-compose up时出现以下错误

找不到 Gemfile 或 .bundle/ 目录
以代码 10 退出

以下是代码。

注意:我已使用 Oracle VM 虚拟盒管理器将代码的父目录作为永久共享文件夹添加到 VM。

有解决问题的想法吗?

Dockerfile

FROM ruby:2.3.0
ENV HTTP_PROXY http://proxy.com:8080
ENV HTTPS_PROXY http://proxy.com:8080
RUN mkdir /student-api
WORKDIR /student-api
ADD Gemfile /student-api/Gemfile
ADD Gemfile.lock /student-api/Gemfile.lock
RUN bundle install
ADD . /student-api

Docker 编写

db:
  image: postgres
  ports:
    - "5432:5432"
web:
  build: .
  command: bundle exec rails s -p 3000 -b '0.0.0.0'
  volumes:
    - .:/student-api
  ports:
    - "3000:3000"
  links:
    - db

【问题讨论】:

  • “。”在哪里在 Windows 上?将 student-api 的卷挂载更改为 Docker 主机目录位置的完整路径,例如/c/Users/joe/dockerproj

标签: ruby-on-rails ruby docker docker-compose


【解决方案1】:

您正在容器中创建 .bundle 目录,然后用主机目录屏蔽它,因为您使用的是卷:

volumes:
    - .:/student-api

您需要在主机上运行bundle install,或者从 Compose 文件中删除卷。

【讨论】:

  • 感谢您的回答。我正在容器中创建捆绑目录,以便可以缓存 gem 并在运行时节省时间。我正在使用卷,因为我打算使用 docker 进行本地开发。这使我不必在每次进行更改时都构建图像。如果我的方法有误,请更正。
  • 我认为你的方法是正确的,它只是强迫你在开发时在主机上运行它。
【解决方案2】:

您是否在 HOME 路径中安装 HOST 目录(例如 c:/Users/john/*)。

请注意,在 HOME 路径之外执行此操作无法正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-17
    • 2019-01-04
    • 1970-01-01
    • 1970-01-01
    • 2015-11-09
    • 2019-07-15
    • 1970-01-01
    相关资源
    最近更新 更多