docker 找不到工头

Foreman not found on docker

我正在尝试为 运行 我的 rails 应用程序创建一个 docker 文件。当我尝试启动容器时,它失败并显示 foreman: executable file not found in $PATH.

Docker 文件

FROM ruby:2.7.2 as builder
ENV RAILS_ENV="production"
COPY . /app
WORKDIR /app
RUN gem install bundler:2.1.4
RUN apt-get update && apt-get install -y nodejs libpq-dev build-essential patch --no-install-recommends && rm -rf /var/lib/apt/lists/*
RUN bundle config set deployment 'true' && \
    bundle config set without 'development test'
RUN bundle install
RUN gem install foreman

FROM ruby:2.7.2
ENV RAILS_ENV="production" \
    RAILS_SERVE_STATIC_FILES="yes"
    # SECRET_KEY_BASE="your_production_key" \
# RUN install_packages libssl1.1
COPY --from=builder /app /app
WORKDIR /app
EXPOSE 3000
CMD ["foreman", "start"]

您在构建器中安装了工头,但您在主容器中执行它。

如果你想运行容器中的一个程序,你需要安装它。