我正在尝试创建一个Rails容器。在我的Dockerfile中,我有以下
# Use the barebones version of Ruby 2.3.
FROM ruby:2.3-slim
# Install dependencies:
# - build-essential: To ensure certain gems can be compiled
# - nodejs: Compile assets
# - libpq-dev: Communicate with postgres through the postgres gem
RUN apt-get update && apt-get install -qq -y --no-install-recommends \
build-essential nodejs libpq-dev
# Set an environment variable to store where the app is installed to inside
# of the Docker image. The name matches the project name out of convention only.
ENV INSTALL_PATH /dockerzon
RUN mkdir -p $INSTALL_PATH
# This sets the context of where commands will be ran in and is documented
# on Docker's website extensively.
WORKDIR $INSTALL_PATH
# Ensure gems are cached and only get updated when they change. This will
# drastically increase build times when your gems do not change.
COPY Gemfile Gemfile
# We want binstubs to be available so we can directly call sidekiq and
# potentially other binaries as command overrides without depending on
# bundle exec.
RUN bundle binstubs bundler --force
RUN bundle install --binstubs
# Copy in the application code from your work station at the current directory
# over to the working directory.
COPY . .
.
.
.
REMAINING FILE TRUNCATED
在容器定义中,我有以下内容 "命令":[" ./ bin / sidekiq"]
当容器运行时,我收到此错误:
您的bin/bundle
不是由Bundler生成的,因此无法运行此binstub。
通过运行bin/bundle
替换bundle binstubs bundler --force
,然后再次运行此命令。
现在,如果我跑
RUN bundle binstubs bundler --force
前
RUN bundle install --binstubs
我收到此错误
Step 8/13 : RUN bundle binstubs bundler --force
---> Running in 6ed1f7228694
Could not find gem 'rails (= 4.2.6)' in any of the gem sources listed in your
Gemfile.
ERROR: Service 'dockerzon' failed to build: The command '/bin/sh -c bundle binstubs bundler --force' returned a non-zero code: 7
答案 0 :(得分:2)
在捆绑安装之前添加RUN bundle binstubs bundler --force
。
捆绑器知道这个问题。请参考: