gpt4 book ai didi

ruby-on-rails - Dockerise rails/redis/sidekiq/postgres 项目

转载 作者:IT王子 更新时间:2023-10-29 06:02:15 29 4
gpt4 key购买 nike

我正在尝试使用 sidekiq、icecast 和 redis 对 Rails 应用程序进行 docker 化以进行流式传输。目前卡在一个错误上,我已经搜索了很长一段时间了。错误回溯:

Successfully built 64c7adaf977d
Successfully tagged radiofm20_sidekiq:latest
Recreating radiofm20_radiofm_1 ...
Recreating radiofm20_radiofm_1 ... done
Attaching to radiofm20_sidekiq_1, radiofm20_radiofm_1
sidekiq_1 | 2018-01-17T23:43:11.163Z 1 TID-6x26s INFO: Booting Sidekiq 5.0.5 with redis options {:url=>"redis://redis:6379", :id=>"Sidekiq-server-PID-1"}
sidekiq_1 | getaddrinfo: Name or service not known
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/connection/ruby.rb:210:in `getaddrinfo'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/connection/ruby.rb:210:in `connect'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/connection/ruby.rb:293:in `connect'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:334:in `establish_connection'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:99:in `block in connect'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:291:in `with_reconnect'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:98:in `connect'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:363:in `ensure_connected'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:219:in `block in process'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:304:in `logging'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:218:in `process'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:185:in `call_pipelined'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:155:in `block in call_pipeline'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:291:in `with_reconnect'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:153:in `call_pipeline'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis.rb:2353:in `block in multi'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis.rb:45:in `block in synchronize'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis.rb:45:in `synchronize'
sidekiq_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis.rb:2345:in `multi'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/client.rb:184:in `block in raw_push'
sidekiq_1 | /usr/local/bundle/gems/connection_pool-2.2.1/lib/connection_pool.rb:64:in `block (2 levels) in with'
sidekiq_1 | /usr/local/bundle/gems/connection_pool-2.2.1/lib/connection_pool.rb:63:in `handle_interrupt'
sidekiq_1 | /usr/local/bundle/gems/connection_pool-2.2.1/lib/connection_pool.rb:63:in `block in with'
sidekiq_1 | /usr/local/bundle/gems/connection_pool-2.2.1/lib/connection_pool.rb:60:in `handle_interrupt'
sidekiq_1 | /usr/local/bundle/gems/connection_pool-2.2.1/lib/connection_pool.rb:60:in `with'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/client.rb:183:in `raw_push'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/client.rb:74:in `push'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/worker.rb:143:in `client_push'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/worker.rb:87:in `perform_async'
sidekiq_1 | /app/config/initializers/sidekiq.rb:10:in `<top (required)>'
sidekiq_1 | /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
sidekiq_1 | /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `block in load'
sidekiq_1 | /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
sidekiq_1 | /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:655:in `block in load_config_initializer'
sidekiq_1 | /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168:in `instrument'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:654:in `load_config_initializer'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:611:in `each'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:611:in `block in <class:Engine>'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `instance_exec'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `run'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:59:in `block in run_initializers'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:48:in `each'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:48:in `tsort_each_child'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:415:in `call'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:415:in `each_strongly_connected_component_from'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:347:in `each'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:347:in `call'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
sidekiq_1 | /usr/local/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:58:in `run_initializers'
sidekiq_1 | /usr/local/bundle/gems/railties-5.1.4/lib/rails/application.rb:353:in `initialize!'
sidekiq_1 | /app/config/environment.rb:5:in `<top (required)>'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/cli.rb:257:in `require'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/cli.rb:257:in `boot_system'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/cli.rb:54:in `run'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-5.0.5/bin/sidekiq:12:in `<top (required)>'
sidekiq_1 | /usr/local/bundle/bin/sidekiq:29:in `load'
sidekiq_1 | /usr/local/bundle/bin/sidekiq:29:in `<main>'
radiofm20_sidekiq_1 exited with code 1
radiofm_1 | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:344:in `rescue in establish_connection': Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:328:in `establish_connection'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:99:in `block in connect'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:291:in `with_reconnect'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:98:in `connect'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:363:in `ensure_connected'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:219:in `block in process'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:304:in `logging'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:218:in `process'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:185:in `call_pipelined'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:155:in `block in call_pipeline'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:291:in `with_reconnect'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:153:in `call_pipeline'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis.rb:2353:in `block in multi'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis.rb:45:in `block in synchronize'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis.rb:45:in `synchronize'
radiofm_1 | from /usr/local/bundle/gems/redis-4.0.1/lib/redis.rb:2345:in `multi'
radiofm_1 | from /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/client.rb:184:in `block in raw_push'
radiofm_1 | from /usr/local/bundle/gems/connection_pool-2.2.1/lib/connection_pool.rb:64:in `block (2 levels) in with'
radiofm_1 | from /usr/local/bundle/gems/connection_pool-2.2.1/lib/connection_pool.rb:63:in `handle_interrupt'
radiofm_1 | from /usr/local/bundle/gems/connection_pool-2.2.1/lib/connection_pool.rb:63:in `block in with'
radiofm_1 | from /usr/local/bundle/gems/connection_pool-2.2.1/lib/connection_pool.rb:60:in `handle_interrupt'
radiofm_1 | from /usr/local/bundle/gems/connection_pool-2.2.1/lib/connection_pool.rb:60:in `with'
radiofm_1 | from /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/client.rb:183:in `raw_push'
radiofm_1 | from /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/client.rb:74:in `push'
radiofm_1 | from /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/worker.rb:143:in `client_push'
radiofm_1 | from /usr/local/bundle/gems/sidekiq-5.0.5/lib/sidekiq/worker.rb:87:in `perform_async'
radiofm_1 | from /app/config/initializers/sidekiq.rb:10:in `<top (required)>'
radiofm_1 | from /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
radiofm_1 | from /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `block in load'
radiofm_1 | from /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
radiofm_1 | from /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:655:in `block in load_config_initializer'
radiofm_1 | from /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168:in `instrument'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:654:in `load_config_initializer'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:611:in `each'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:611:in `block in <class:Engine>'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `instance_exec'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `run'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:59:in `block in run_initializers'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:48:in `each'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:48:in `tsort_each_child'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:415:in `call'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:415:in `each_strongly_connected_component_from'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:347:in `each'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:347:in `call'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
radiofm_1 | from /usr/local/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/initializable.rb:58:in `run_initializers'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/application.rb:353:in `initialize!'
radiofm_1 | from /app/config/environment.rb:5:in `<top (required)>'
radiofm_1 | from config.ru:3:in `require_relative'
radiofm_1 | from config.ru:3:in `block in <main>'
radiofm_1 | from /usr/local/bundle/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
radiofm_1 | from /usr/local/bundle/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
radiofm_1 | from config.ru:in `new'
radiofm_1 | from config.ru:in `<main>'
radiofm_1 | from /usr/local/bundle/gems/rack-2.0.3/lib/rack/builder.rb:49:in `eval'
radiofm_1 | from /usr/local/bundle/gems/rack-2.0.3/lib/rack/builder.rb:49:in `new_from_string'
radiofm_1 | from /usr/local/bundle/gems/rack-2.0.3/lib/rack/builder.rb:40:in `parse_file'
radiofm_1 | from /usr/local/bundle/gems/rack-2.0.3/lib/rack/server.rb:319:in `build_app_and_options_from_config'
radiofm_1 | from /usr/local/bundle/gems/rack-2.0.3/lib/rack/server.rb:219:in `app'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:24:in `app'
radiofm_1 | from /usr/local/bundle/gems/rack-2.0.3/lib/rack/server.rb:354:in `wrapped_app'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:80:in `log_to_stdout'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:42:in `start'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:135:in `block in perform'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `tap'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `perform'
radiofm_1 | from /usr/local/bundle/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
radiofm_1 | from /usr/local/bundle/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
radiofm_1 | from /usr/local/bundle/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
radiofm_1 | from /usr/local/bundle/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
radiofm_1 | from /app/bin/rails:9:in `require'
radiofm_1 | from /app/bin/rails:9:in `<top (required)>'
radiofm_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
radiofm_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
radiofm_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
radiofm_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
radiofm_1 | from /usr/local/bundle/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
radiofm_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
radiofm_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
radiofm_1 | from /app/bin/spring:15:in `require'
radiofm_1 | from /app/bin/spring:15:in `<top (required)>'
radiofm_1 | from bin/rails:3:in `load'
radiofm_1 | from bin/rails:3:in `<main>'
radiofm_1 | => Booting Puma
radiofm_1 | => Rails 5.1.4 application starting in development
radiofm_1 | => Run `rails server -h` for more startup options
radiofm_1 | Exiting
radiofm20_radiofm_1 exited with code 1

docker 组成:

  radiofm:
build:
context: "./"
dockerfile: Dockerfile-development
volumes:
- .:/src
env_file:
- './src/.env'
environment:
- REDIS-URL=redis://redis:6379/0
ports:
- "3000:3000"

sidekiq:
command: sidekiq -C config/sidekiq.yml.erb
build: .
volumes:
- '.:/src'
env_file:
- './src/.env'
volumes:
postgres:
sidekiq:

Dockerfile(有点乱,多多包涵)

FROM ruby:2.4.3

ENV DEBIAN_FRONTEND noninteractive
ENV BUILD_PACKAGES curl-dev build-base
RUN apt-get update
RUN apt-get install -y libpq-dev git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev
RUN apt-get install -y apt-utils

RUN wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
apt-key add -
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
postgresql-client-9.6 \
&& rm -rf /var/lib/apt/lists/*t
# Node.js
RUN apt-get install -y nodejs

# for nokogiri
RUN apt-get install -y libxml2-dev libxslt1-dev


# for capybara-webkit
RUN apt-get install -y libqt4-webkit libqt4-dev xvfb


#For Ruby-shout
RUN apt-get install -y libxml2 libxslt1-dev python-dev
RUN apt-get update && apt-get install -y \
curl
RUN apt-get install -y vorbis-tools
RUN apt-get install -y libshout3-dev


#Icecast
RUN sh -c "echo deb http://download.opensuse.org/repositories/multimedia:/xiph/xUbuntu_16.04/ ./ >>/etc/apt/sources.list.d/icecast.list"
RUN apt install wget
RUN wget -qO - http://icecast.org/multimedia-obs.key | apt-key add -
RUN apt-get update
RUN apt-get install icecast2




RUN rm -rf /var/lib/gems/2.4.1/cache/*
#ICECAST DEPENDENCY INSTALL REDIS+DEPENDENCY ICECAST
RUN apt-get install -y redis-server
RUN redis-server --daemonize yes
# RUN redis-server --version
RUN mkdir /app

WORKDIR /app

COPY /src /app


RUN gem install bundler
RUN gem install rake
RUN bundle install

EXPOSE 3000
CMD rails db:create
CMD rails db:migrate
CMD rails s -p 3000 -b 0.0.0.0

我怎样才能解决这个 getaddrinfo 错误?我的想法是,这是 sidekiq 和 redis 之间的某种连接错误。我的 sidekiq.rb 配置文件中也有这个

 Sidekiq.configure_server do |config|
config.redis = { url: 'redis://redis:6379' }
end

提前致谢。抱歉,如果我的帖子有点模棱两可。随便问什么。 :)

编辑:我使用这个 sidekiq.rb 文件部署了基本的 Rails 应用程序(可以在端口 localhost:3000 上收听它)但是现在我得到了这个错误

web_1  | /usr/local/bundle/gems/redis-4.0.1/lib/redis/connection/ruby.rb:210:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError)

sidekiq.rb 文件:

Sidekiq.configure_server do |config|
config.redis = { url: 'redis://redis:6379' }
end
Sidekiq.configure_client do |config|
config.redis = { url: 'redis://redis:6379'}
end

RadioWorker.perform_async
TestWorker.perform_async
JazzWorker.perform_async

更新:修复了 redis 错误现在面临 dockerizing POSTGRES 的问题在 localhost:3000 上运行应用程序时,我收到此错误消息:https://imgur.com/a/YXw8N

我的 docker-compose 文件:

version: "3.0"
services:
postgres:
image: 'postgres:9.6'
environment:
- PGDATA=/var/lib/postgresql/data/pgdata
- POSTGRES_PASSWORD=
- POSTGRES_USER=postgres
networks:
- default
volumes:
- 'postgres:/var/lib/postgresql/data'
labels:
description: "Postgresql Database"
service: "postgresql"
redis:
image: redis
ports:
- 6379:6379
volumes:
- 'redis:/data'
command: redis-server --appendonly yes
web:
build:
context: "./"
dockerfile: Dockerfile-development
volumes:
- .:/src
env_file:
- './src/.env'
environment:
- REDIS-URL=redis://redis:6379/
- POSTGRES-URL=postgres://postgres:5432/
depends_on:
- redis
- postgres
ports:
- "3000:3000"
volumes:
redis:
postgres:

最佳答案

Dockerfile 用于构建镜像,而不是用于运行守护进程。 docker build 的结果是一个静态的东西(docker image)。我建议你直接从 docker-compose.yml 运行 redis

redis:
image: redis

radiofm:
(...)
depends_on: redis
(...)

PostgreSQL 的情况类似。如果你真的想在容器启动时设置你的图像以运行守护进程,你应该用脚本调整 CMD。

此外,您只能使用一次 CMD。

关于ruby-on-rails - Dockerise rails/redis/sidekiq/postgres 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48311901/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com