我正在尝试在此处构建示例应用。 http://codepany.com/blog/rails-5-and-docker-puma-nginx/
当我运行docker-compose build时:
Step 1/13 : FROM ruby:2.4-alpine
---> 64419e20d6c5
Step 2/13 : RUN apt-get update -qq && apt-get install -y build-
essential libpq-dev nodejs
---> Running in 98d4ed713984
/bin/sh: apt-get: not found
ERROR: Service 'app' failed to build: The command '/bin/sh -c apt-
get update -qq && apt-get install -y build-essential libpq-dev
nodejs' returned a non-zero code: 127
Dockerfile:
FROM ruby:2.4-alpine
# Base image:
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/sample_rails_docker_app
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran:
WORKDIR $RAILS_ROOT
# Gems:
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN gem install bundler
RUN bundle install
COPY config/puma.rb config/puma.rb
# Copy the main application.
COPY . .
EXPOSE 3000
# The default command that gets ran will be to start the Puma server.
CMD bundle exec puma -C config/puma.rb
答案 0 :(得分:0)
感谢您的评论,我使用了以下内容:
ruby 2.4.1
安装rpm
。FROM ruby:2.4-alpine
。 (教程使用ruby 3.2.1)在docker中安装ruby:2.4.1
后,我用ruby2.4.1-alpine_rails
替换了ruby。