Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails服务器未以Docker启动_Ruby On Rails_Docker - Fatal编程技术网

Ruby on rails Rails服务器未以Docker启动

Ruby on rails Rails服务器未以Docker启动,ruby-on-rails,docker,Ruby On Rails,Docker,我试图使用docker部署RubyonRails项目,但遇到了一些问题。我的Dockerfile看起来像这样 FROM ruby:2.6.3 WORKDIR /usr/src/app RUN apt-get update -qq && \ apt-get install -y nodejs && \ gem install --no-document rails -v 5.2.3 COPY ./Gemfile ./Gemfile.lock ./

我试图使用docker部署RubyonRails项目,但遇到了一些问题。我的Dockerfile看起来像这样

FROM ruby:2.6.3
WORKDIR /usr/src/app

RUN apt-get update -qq && \
    apt-get install -y nodejs && \
    gem install --no-document rails -v 5.2.3

COPY ./Gemfile ./Gemfile.lock ./
COPY ./.gemrc ~/

RUN printf "gem: --no-rdoc --no-ri --no-document" | tee /etc/gemrc ~/.gemrc && \
    gem install bundler -v '2.1.4'
RUN bundle install --jobs 2

COPY . .

COPY ./docker-entrypoint.sh /usr/bin
RUN chmod +x /usr/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 3000

CMD ["rails", "server", "puma"]
#!/bin/sh
set -e

if [ -f tmp/pids/server.pid ]; then
  rm tmp/pids/server.pid
fi

exec bundle exec "$@"
docker entrypoint.sh
用于确保服务器不会重复使用pid,如下所示

FROM ruby:2.6.3
WORKDIR /usr/src/app

RUN apt-get update -qq && \
    apt-get install -y nodejs && \
    gem install --no-document rails -v 5.2.3

COPY ./Gemfile ./Gemfile.lock ./
COPY ./.gemrc ~/

RUN printf "gem: --no-rdoc --no-ri --no-document" | tee /etc/gemrc ~/.gemrc && \
    gem install bundler -v '2.1.4'
RUN bundle install --jobs 2

COPY . .

COPY ./docker-entrypoint.sh /usr/bin
RUN chmod +x /usr/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 3000

CMD ["rails", "server", "puma"]
#!/bin/sh
set -e

if [ -f tmp/pids/server.pid ]; then
  rm tmp/pids/server.pid
fi

exec bundle exec "$@"
使用
docker build-t rails\u app
成功生成图像,但当我使用
docker run-p 3000:3000 rails\u app
运行图像时,不会抛出任何错误,但屏幕上不会显示任何输出。然后,当我点击Control-C停止容器时,它会给我puma服务器的输出,然后启动并停止自身

docker run -p 3000:3000 rails_app
^C=> Booting Puma
=> Rails 5.2.4.2 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.4 (ruby 2.6.3-p62), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2020-04-19 21:42:28 +0000 ===
Goodbye!
Exiting
在我关闭容器之前,容器启动服务器需要做什么?此外,在点击Control-C之前,在localhost:3000上找不到任何东西,因此服务器没有静默启动