我有一个以
开头的rails项目docker-compose up
然而,每当我启动它时,docker-compose输出所有先前容器的日志,并且它越来越多......
如何限制启动时登录的输出?
这是我的docker-compose.yml,它有帮助...
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
environment:
RAILS_ENV: development
volumes:
- .:/rcd
ports:
- "3000:3000"
external_links:
- postgres:db
volumes_from:
- bundle
bundle:
image: rcd_web
command: echo "hi"
volumes:
- /bundle
这里是Dockerfile:
FROM ruby:2.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
ENV APP_HOME /rcd
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD Gemfile* $APP_HOME/
ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \
BUNDLE_JOBS=2 \
BUNDLE_PATH=/bundle
RUN bundle install --without production development test
ADD . $APP_HOME
ENV PATH ~/bin:$PATH
我当然可以删除所有旧容器:
docker rm `docker ps -aq`
但我不想在每次启动时都这样做..
这里是f.ex.三次停止/开始后记录
~/workspace/rcd$ docker-compose up
Starting rcd_bundle_1...
Starting rcd_web_1...
Attaching to rcd_bundle_1, rcd_web_1
bundle_1 | hi
bundle_1 | hi
bundle_1 | hi
web_1 | => Booting WEBrick
web_1 | => Rails 4.2.4 application starting in development on http://0.0.0.0:3000
web_1 | => Run `rails server -h` for more startup options
web_1 | => Ctrl-C to shutdown server
web_1 | Exiting
web_1 | [2015-11-17 11:52:16] INFO WEBrick 1.3.1
web_1 | [2015-11-17 11:52:16] INFO ruby 2.1.7 (2015-08-18) [x86_64-linux]
web_1 | [2015-11-17 11:52:16] INFO WEBrick::HTTPServer#start: pid=1 port=3000
web_1 | [2015-11-17 11:52:16] FATAL SignalException: SIGTERM
web_1 | /usr/local/lib/ruby/2.1.0/webrick/server.rb:170:in `select'
web_1 | /usr/local/lib/ruby/2.1.0/webrick/server.rb:170:in `block in start'
web_1 | /usr/local/lib/ruby/2.1.0/webrick/server.rb:32:in `start'
web_1 | /usr/local/lib/ruby/2.1.0/webrick/server.rb:160:in `start'
web_1 | /bundle/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in `run'
web_1 | /bundle/gems/rack-1.6.4/lib/rack/server.rb:286:in `start'
web_1 | /bundle/gems/railties-4.2.4/lib/rails/commands/server.rb:80:in `start'
web_1 | /bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:80:in `block in server'
web_1 | /bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap'
web_1 | /bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server'
web_1 | /bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
web_1 | /bundle/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
web_1 | bin/rails:8:in `require'
web_1 | bin/rails:8:in `<main>'
web_1 | [2015-11-17 11:52:16] INFO going to shutdown ...
web_1 | [2015-11-17 11:52:16] INFO WEBrick::HTTPServer#start done.
web_1 | => Booting WEBrick
web_1 | => Rails 4.2.4 application starting in development on http://0.0.0.0:3000
web_1 | => Run `rails server -h` for more startup options
web_1 | => Ctrl-C to shutdown server
web_1 | Exiting
web_1 | [2015-11-17 11:52:22] INFO WEBrick 1.3.1
web_1 | [2015-11-17 11:52:22] INFO ruby 2.1.7 (2015-08-18) [x86_64-linux]
web_1 | [2015-11-17 11:52:22] INFO WEBrick::HTTPServer#start: pid=1 port=3000
答案 0 :(得分:2)
我认为此问题已在docker-compose 1.5中修复。您只能从启动容器的时间获取日志。