Docker撰写,导轨和绑定的开发环境 – 有点破碎

我想使用docker-compose的绑定挂载来允许我自己对rails控制器进行修改,并让它们立即显示在我的dev服务器上,而不必重新编译映像。

如果我创build了一个没有绑定装载的API镜像,连接了dockerfile,它就能正常工作 – 没有错误,function正确,但是我没有select在运行中修改。

不幸的是,当我添加一个绑定挂载,以掩盖我的应用程序工作文件夹上的容器时,我在docker-compose输出中出现以下错误:

api_1 | bundler: failed to load command: rails (/usr/local/bundle/bin/rails) api_1 | Bundler::GemNotFound: Could not find rake-12.2.1 in any of the sources api_1 | /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/spec_set.rb:88:in `block in materialize' api_1 | /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/spec_set.rb:82:in `map!' api_1 | /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/spec_set.rb:82:in `materialize' api_1 | /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/definition.rb:170:in `specs' api_1 | /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/definition.rb:237:in `specs_for' api_1 | /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/definition.rb:226:in `requested_specs' api_1 | /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:108:in `block in definition_method' api_1 | /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:20:in `setup' api_1 | /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler.rb:107:in `setup' api_1 | /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/setup.rb:20:in `<top (required)>' api_1 | /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require' api_1 | /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require' pitot_api_1 exited with code 1 

我的API的Dockerfile:

 FROM ruby:2.4.2 RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs RUN mkdir /pitot WORKDIR /pitot COPY ./Gemfile* /pitot RUN bundle install COPY . /pitot # Expose a volume so that nginx will be able to read in assets in production. VOLUME ["$INSTALL_PATH/public"] #Expose port 8080 EXPOSE 8080 

我的docker的位组成:

 version: "3" services: api: build: . command: bundle exec rails server --port 8080 --binding 0.0.0.0 links: - postgres - mailcatcher - pitot-solr-sunspot volumes: - .:/pitot ports: - '8080:8080' env_file: - .pitot.env <SNIP> 

我最初的预感是在/皮托项目文件夹(我的本地文件夹)的绑定版本中有一些东西对我的环境做了一些非常奇怪的事情。 我不能真正追踪它。

请注意,容器上的gem env的输出与/ pitot中的绑定安装相同或不同:

 api_1 | RubyGems Environment: api_1 | - RUBYGEMS VERSION: 2.6.14 api_1 | - RUBY VERSION: 2.4.2 (2017-09-14 patchlevel 198) [x86_64-linux] api_1 | - INSTALLATION DIRECTORY: /usr/local/bundle api_1 | - USER INSTALLATION DIRECTORY: /root/.gem/ruby/2.4.0 api_1 | - RUBY EXECUTABLE: /usr/local/bin/ruby api_1 | - EXECUTABLE DIRECTORY: /usr/local/bundle/bin api_1 | - SPEC CACHE DIRECTORY: /root/.gem/specs api_1 | - SYSTEM CONFIGURATION DIRECTORY: /usr/local/etc api_1 | - RUBYGEMS PLATFORMS: api_1 | - ruby api_1 | - x86_64-linux api_1 | - GEM PATHS: api_1 | - /usr/local/bundle api_1 | - /root/.gem/ruby/2.4.0 api_1 | - /usr/local/lib/ruby/gems/2.4.0 api_1 | - GEM CONFIGURATION: api_1 | - :update_sources => true api_1 | - :verbose => true api_1 | - :backtrace => false api_1 | - :bulk_threshold => 1000 api_1 | - "install" => "--no-document" api_1 | - "update" => "--no-document" api_1 | - REMOTE SOURCES: api_1 | - https://rubygems.org/ api_1 | - SHELL PATH: api_1 | - /usr/local/bundle/bin api_1 | - /usr/local/sbin api_1 | - /usr/local/bin api_1 | - /usr/sbin api_1 | - /usr/bin api_1 | - /sbin api_1 | - /bin