docker-compose构建失败,使用/ bin / sh:apt-get:not found

时间:2017-09-21 23:06:52

标签: docker docker-compose dockerfile alpine

我正在尝试在此处构建示例应用。 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 个答案:

答案 0 :(得分:0)

感谢您的评论,我使用了以下内容:

  1. 使用ruby 2.4.1安装rpm
  2. Dockerfile已更新为FROM ruby:2.4-alpine。 (教程使用ruby 3.2.1)
  3. 在docker中安装ruby:2.4.1后,我用ruby2.4.1-alpine_rails替换了ruby。