Docker içindeki Rails uygulamama erişemiyorum

Öncelikle herkese iyi forumlar.
Docker kullanarak rails uygulamamı çalıştırmaya çalışıyorum fakat herşeyi doğru şekilde yapmama rağmen şu hatayı alıyorum:

#<Errno::EADDRNOTAVAIL: Failed to open TCP connection to localhost:35729 (Cannot assign requested address - connect(2) for "localhost" port 35729)>
web_1  | 2023-09-25 09:25:39 +0000 Rack app ("GET /" - (172.25.0.1)): #<Errno::EADDRNOTAVAIL: Failed to open TCP connection to localhost:35729 (Cannot assign requested address - connect(2) for "localhost" port 35729)>

Başka uygulamalarda da benzer Dockerfile ve docker-compose.yaml bulunmasına rağmen sadece bu uygulamamda hata alıyorum ve uğraşmama rağmen birtürlü çözemedim.

Dockerfile:

FROM ruby:3.0.1

RUN apt update -y && apt upgrade -y && apt install -y nodejs postgresql-client build-essential npm && npm install --global yarn

WORKDIR /app

COPY . /app

COPY Gemfile* ./app

RUN bundle install && bundle update

docker-compose.yaml:

version: "3"

services:
    web:
        build: .
        command: /bin/sh -c "rm -f /app/tmp/pids/server.pid && yarn install --ignore-engines && bin/rails db:migrate RAILS_ENV=development && bin/rails webpacker:compile && bundle exec rails server -u puma -p 3001 -b '0.0.0.0'"
        volumes:
            - .:/app
        depends_on:
            - db
        ports:
            - "3001:3001"
    db:
        image: postgres
        volumes:
            - ./tmp/db:/var/postgresql/data
        environment:
            - POSTGRES_USER=wormer
            - POSTGRES_PASSWORD=wormer-
            - POSTGRES_DB=deneme

database.yml:

default: &default
  adapter: postgresql
  encoding: unicode
  username: wormer
  password: wormer-
  host: 172.25.0.2
  port: 5432
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  #adapter: sqlite3

development:
  <<: *default
  database: deneme
  #database: db/deneme.db
test:
  <<: *default
  database: Api_Test_test

production:
  <<: *default
  database: Api_Test_production
  username: Api_Test
  password: <%= ENV["API_TEST_DATABASE_PASSWORD"] %>

Detaylı olarak aldığım hata:

Puma caught this error: Failed to open TCP connection to localhost:35729 (Cannot assign requested address - connect(2) for "localhost" port 35729) (Errno::EADDRNOTAVAIL)
/usr/local/lib/ruby/3.0.0/net/http.rb:987:in `initialize'
/usr/local/lib/ruby/3.0.0/net/http.rb:987:in `open'
/usr/local/lib/ruby/3.0.0/net/http.rb:987:in `block in connect'
/usr/local/lib/ruby/3.0.0/timeout.rb:97:in `block in timeout'
/usr/local/lib/ruby/3.0.0/timeout.rb:107:in `timeout'
/usr/local/lib/ruby/3.0.0/net/http.rb:985:in `connect'
/usr/local/lib/ruby/3.0.0/net/http.rb:970:in `do_start'
/usr/local/lib/ruby/3.0.0/net/http.rb:959:in `start'
/usr/local/lib/ruby/3.0.0/net/http.rb:1512:in `request'
/usr/local/bundle/gems/rack-mini-profiler-2.3.4/lib/patches/net_patches.rb:19:in `block in request_with_mini_profiler'
/usr/local/bundle/gems/rack-mini-profiler-2.3.4/lib/mini_profiler/profiling_methods.rb:40:in `step'
/usr/local/bundle/gems/rack-mini-profiler-2.3.4/lib/patches/net_patches.rb:18:in `request_with_mini_profiler'
/usr/local/lib/ruby/3.0.0/net/http.rb:1492:in `send_request'
/usr/local/bundle/gems/rack-livereload-0.3.17/lib/rack/livereload/body_processor.rb:50:in `use_vendored?'
/usr/local/bundle/gems/rack-livereload-0.3.17/lib/rack/livereload/body_processor.rb:101:in `livereload_source'
(erb):14:in `block (2 levels) in process!'
/usr/local/lib/ruby/3.0.0/erb.rb:905:in `eval'
/usr/local/lib/ruby/3.0.0/erb.rb:905:in `result'
/usr/local/bundle/gems/rack-livereload-0.3.17/lib/rack/livereload/body_processor.rb:78:in `block (2 levels) in process!'
/usr/local/bundle/gems/activesupport-6.1.7/lib/active_support/core_ext/string/output_safety.rb:311:in `block in gsub!'
/usr/local/bundle/gems/activesupport-6.1.7/lib/active_support/core_ext/string/output_safety.rb:309:in `gsub!'
/usr/local/bundle/gems/activesupport-6.1.7/lib/active_support/core_ext/string/output_safety.rb:309:in `gsub!'
/usr/local/bundle/gems/rack-livereload-0.3.17/lib/rack/livereload/body_processor.rb:78:in `block in process!'
/usr/local/bundle/gems/rack-livereload-0.3.17/lib/rack/livereload/body_processor.rb:76:in `each'
/usr/local/bundle/gems/rack-livereload-0.3.17/lib/rack/livereload/body_processor.rb:76:in `process!'
/usr/local/bundle/gems/rack-livereload-0.3.17/lib/rack/livereload.rb:28:in `_call'
/usr/local/bundle/gems/rack-livereload-0.3.17/lib/rack/livereload.rb:14:in `call'
/usr/local/bundle/gems/actionpack-6.1.7/lib/action_dispatch/middleware/static.rb:24:in `call'
/usr/local/bundle/gems/rack-2.2.4/lib/rack/sendfile.rb:110:in `call'
/usr/local/bundle/gems/actionpack-6.1.7/lib/action_dispatch/middleware/host_authorization.rb:148:in `call'
/usr/local/bundle/gems/rack-mini-profiler-2.3.4/lib/mini_profiler/profiler.rb:393:in `call'
/usr/local/bundle/gems/rack-cors-1.1.1/lib/rack/cors.rb:100:in `call'
/usr/local/bundle/gems/webpacker-5.4.3/lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
/usr/local/bundle/gems/rack-proxy-0.7.4/lib/rack/proxy.rb:78:in `call'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/engine.rb:539:in `call'
/usr/local/bundle/gems/puma-5.6.5/lib/puma/configuration.rb:252:in `call'
/usr/local/bundle/gems/puma-5.6.5/lib/puma/request.rb:77:in `block in handle_request'
/usr/local/bundle/gems/puma-5.6.5/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
/usr/local/bundle/gems/puma-5.6.5/lib/puma/request.rb:76:in `handle_request'
/usr/local/bundle/gems/puma-5.6.5/lib/puma/server.rb:443:in `process_client'
/usr/local/bundle/gems/puma-5.6.5/lib/puma/thread_pool.rb:147:in `block in spawn_thread'

Yardımcı olucak hocalarıma şimdiden teşekkürler.

Su senin yasadigin sorunun aynisi gibi duruyor: Failed to open TCP connection to localhost:35729 (Cannot assign requested address - connect(2) for "localhost" port 35729) · Issue #340 · locomotivecms/wagon · GitHub

1 Beğeni

Çok teşşekür ederim hocam beni büyük bir dertten kurtardınız :slight_smile: