docker-compose构build失败/ bin / sh:apt-get:not found

我正在尝试在这里构build示例应用程序。 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 

感谢您的意见,我做了以下工作:

  1. rpm安装ruby 2.4.1
  2. Dockerfile更新为FROM ruby:2.4-alpine 。 (教程使用ruby 3.2.1)

我用rubyreplace了ruby:2.4.1ruby2.4.1-alpine_rails中安装ruby2.4.1-alpine_rails之后。