【问题标题】:Puma silently exits inside docker containerPuma 在 docker 容器内默默退出
【发布时间】:2019-09-19 15:10:27
【问题描述】:

Rails 5.2.3

Puma 3.12.1

我已经 dockerized 我的 rails 应用程序,当我使用命令 rails s puma 启动容器时,Puma 启动然后静默退出:

=> Booting Puma
=> Rails 5.2.3 application starting in production 
=> Run `rails server -h` for more startup options

此后不再有日志,容器不再运行。 Puma 在 docker 之外仍然可以正常工作。

有什么想法吗?

编辑

Dockerfile

FROM ruby:2.4.5
RUN sed -i '/jessie-updates/d' /etc/apt/sources.list

RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
    apt-get update -qq && apt-get install -y build-essential nodejs && \
    apt-get clean

RUN gem install bundler  # ensure bundler 2
RUN gem cleanup

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
    apt-get update && apt-get install -y apt-utils yarn && \
    gem install rails -v 5.2.3

ARG environment
RUN echo $environment
ENV RAILS_ENV=$environment
ENV DOCKER_IMAGE_BUILD=true

# ------------------------
# SSH Server support
# ------------------------
RUN apt-get update \
    && apt-get install -y --no-install-recommends openssh-server build-essential nodejs cron nano systemd \
    && echo "root:Docker!" | chpasswd

COPY sshd_config /etc/ssh/

RUN mkdir /myapp
WORKDIR /myapp
COPY . /myapp

RUN bundle -v

RUN bundle install
RUN yarn install


EXPOSE 3000 2222

COPY init_container.sh /myapp
RUN chmod 755 /myapp/init_container.sh

ENTRYPOINT ["/myapp/init_container.sh"]

init_container.sh:

#!/usr/bin/env bash
cat >/etc/motd <<EOL
  _____
  /  _  \ __________ _________   ____
/  /_\  \\___   /  |  \_  __ \_/ __ \
/    |    \/    /|  |  /|  | \/\  ___/
\____|__  /_____ \____/ |__|    \___  >
        \/      \/                  \/
A P P   S E R V I C E   O N   L I N U X

Documentation: http://aka.ms/webapp-linux
NodeJS quickstart: https://aka.ms/node-qs

EOL
cat /etc/motd

service ssh start

# whenever has to be run from the main app folder.
# it will look for schedule.rb in /myapp/config folder
cd /myapp
whenever --update-crontab
# restart cron after updating crontab
service cron restart
# for logging
crontab -l

bundle exec rails assets:precompile
yarn install

rails s puma

【问题讨论】:

  • 能否请您发布用于创建此容器映像的 dockerfile?启动容器的命令是什么?
  • @VigneshSP 完成

标签: ruby-on-rails docker puma


【解决方案1】:

不是 ruby​​ 专家,但我会这样做以了解发生了什么。

Bash 进入容器,查看您在/myapp 目录中复制的应用文件是否确实存在。

docker exec -it &lt;container name&gt; /bin/bash

如果有,请尝试手动运行./init_container.sh 看看会发生什么。

使用 bash,您实际上可以检查日志并找出容器仍在运行时发生的情况。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-20
    • 2021-07-26
    • 2019-07-30
    • 2022-01-25
    • 2016-02-13
    • 1970-01-01
    • 2015-04-30
    相关资源
    最近更新 更多