Rails、Webpacker 和 Docker:无法分配请求的地址 - connect(2) for [::1]:3035

Rails, Webpacker, and Docker : Cannot assign requested address - connect(2) for [::1]:3035

我正在尝试让 webpackerdockerpuma 3.10.0rails 5.1.4webpacker 3.0.1 一起工作。

我为 docker 设置了以下配置:

Dockerfile

FROM ruby:2.4.1

ENV DIR=/app \
    BUNDLE_JOBS=4

RUN curl -sL https://deb.nodesource.com/setup_7.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs openssl yarn

RUN mkdir $DIR
WORKDIR $DIR

ADD Gemfile $DIR/Gemfile
ADD Gemfile.lock $DIR/Gemfile.lock

RUN bundle install
RUN gem install foreman

ADD . $DIR

EXPOSE 3000

ADD docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

CMD bundle exec rails s -p 3000 -b 0.0.0.0

docker-compose.yml

version: "2"

services:
  db:
    image: postgres
    env_file:
      - docker.env
  webpacker:
    build: .
    command: bundle exec bin/webpack-dev-server
    ports:
      - "8080:8080"
  app:
    build: .
    links:
      - db:db
    ports:
      - "3000:3000"
    depends_on:
      - db
      - webpacker
    env_file:
      - docker.env
    command: bundle exec rails s -p 3000 -b '0.0.0.0'

不幸的是,每当我 运行 docker-compose up 并访问 localhost:3000 时,我都会收到以下错误:

#<Errno::EADDRNOTAVAIL: Cannot assign requested address - connect(2) for [::1]:3035>

非常感谢任何帮助。谢谢大家。


EDIT 下面是来自我的 webpack 和应用程序容器的日志:

webpacker_1  |
webpacker_1  | Project is running at http://localhost:3035/
webpacker_1  | webpack output is served from /packs/
webpacker_1  | Content not from webpack is served from /app/public/packs
webpacker_1  | 404s will fallback to /index.html
webpacker_1  | Running /app/node_modules/.bin/elm-make /app/app/javascript/packs/Main.elm --yes --warn --debug --output /tmp/117813-1-17kg4e0.13yc01wcdi.js
webpacker_1  |  14% building modules 40/57 Success! Compiled 1 module./lib/transport/xhr-streaming.js
webpacker_1  | Successfully generated /tmp/117813-1-17kg4e0.13yc01wcdi.js
webpacker_1  |
 94% asset optimHash: 0fba3c9f83d08f099017
webpacker_1  | Version: webpack 3.5.6
webpacker_1  | Time: 4214ms
webpacker_1  |                               Asset       Size  Chunks                    Chunk Names
webpacker_1  |   hello_elm-a49ad0a3ed48411416eb.js    1.87 MB       0  [emitted]  [big]  hello_elm
webpacker_1  |        Main-f0a26307d1db1882a32b.js    1.87 MB       1  [emitted]  [big]  Main
webpacker_1  | application-963cd78993444428f61c.js     896 kB       2  [emitted]  [big]  application
webpacker_1  |                       manifest.json  182 bytes          [emitted]
webpacker_1  |   [34] (webpack)-dev-server/client?http://localhost:3035 5.83 kB {0} {1} {2} [built]
webpacker_1  |   [35] ./node_modules/url/url.js 23.3 kB {0} {1} {2} [built]
webpacker_1  |   [41] ./node_modules/strip-ansi/index.js 161 bytes {0} {1} {2} [built]
webpacker_1  |   [43] ./node_modules/loglevel/lib/loglevel.js 7.74 kB {0} {1} {2} [built]
webpacker_1  |   [44] (webpack)-dev-server/client/socket.js 856 bytes {0} {1} {2} [built]
webpacker_1  |   [45] ./node_modules/sockjs-client/lib/entry.js 244 bytes {0} {1} {2} [built]
webpacker_1  |   [77] (webpack)-dev-server/client/overlay.js 3.6 kB {0} {1} {2} [built]
webpacker_1  |   [82] (webpack)/hot nonrecursive ^\.\/log$ 170 bytes {0} {1} {2} [built]
webpacker_1  |   [84] (webpack)/hot/emitter.js 77 bytes {0} {1} {2} [built]
webpacker_1  |   [86] ./app/javascript/packs/Main.elm 335 kB {0} {1} [built]
webpacker_1  |   [87] multi (webpack)-dev-server/client?http://localhost:3035 ./app/javascript/packs/application.js 40 bytes {2} [built]
webpacker_1  |   [88] ./app/javascript/packs/application.js 515 bytes {2} [built]
webpacker_1  |   [89] multi (webpack)-dev-server/client?http://localhost:3035 ./app/javascript/packs/hello_elm.js 40 bytes {0} [built]
webpacker_1  |   [90] ./app/javascript/packs/hello_elm.js 396 bytes {0} [built]
webpacker_1  |   [91] multi (webpack)-dev-server/client?http://localhost:3035 ./app/javascript/packs/Main.elm 40 bytes {1} [built]
webpacker_1  |     + 77 hidden modules
webpacker_1  | webpack: Compiled successfully.

webpacker_1  | Project is running at http://localhost:3035/
webpacker_1  | webpack output is served from /packs/
webpacker_1  | Content not from webpack is served from /app/public/packs
webpacker_1  | 404s will fallback to /index.html
webpacker_1  | Running /app/node_modules/.bin/elm-make /app/app/javascript/packs/Main.elm --yes --warn --debug --output /tmp/117813-1-1lm55js.r9mkgzm2t9.js
webpacker_1  |  14% building modules 40/57 modules 17 active ...ockjsSuccess! Compiled 1 module.et.js
webpacker_1  | Successfully generated /tmp/117813-1-1lm55js.r9mkgzm2t9.js
webpacker_1  |
 92% chunk assetHash: 0fba3c9f83d08f099017
webpacker_1  | Version: webpack 3.5.6
webpacker_1  | Time: 3059ms
webpacker_1  |                               Asset       Size  Chunks                    Chunk Names
webpacker_1  |   hello_elm-a49ad0a3ed48411416eb.js    1.87 MB       0  [emitted]  [big]  hello_elm
webpacker_1  |        Main-f0a26307d1db1882a32b.js    1.87 MB       1  [emitted]  [big]  Main
webpacker_1  | application-963cd78993444428f61c.js     896 kB       2  [emitted]  [big]  application
webpacker_1  |                       manifest.json  182 bytes          [emitted]
webpacker_1  |   [34] (webpack)-dev-server/client?http://localhost:3035 5.83 kB {0} {1} {2} [built]
webpacker_1  |   [35] ./node_modules/url/url.js 23.3 kB {0} {1} {2} [built]
webpacker_1  |   [41] ./node_modules/strip-ansi/index.js 161 bytes {0} {1} {2} [built]
webpacker_1  |   [43] ./node_modules/loglevel/lib/loglevel.js 7.74 kB {0} {1} {2} [built]
webpacker_1  |   [44] (webpack)-dev-server/client/socket.js 856 bytes {0} {1} {2} [built]
webpacker_1  |   [45] ./node_modules/sockjs-client/lib/entry.js 244 bytes {0} {1} {2} [built]
webpacker_1  |   [77] (webpack)-dev-server/client/overlay.js 3.6 kB {0} {1} {2} [built]
webpacker_1  |   [82] (webpack)/hot nonrecursive ^\.\/log$ 170 bytes {0} {1} {2} [built]
webpacker_1  |   [84] (webpack)/hot/emitter.js 77 bytes {0} {1} {2} [built]
webpacker_1  |   [86] ./app/javascript/packs/Main.elm 335 kB {0} {1} [built]
webpacker_1  |   [87] multi (webpack)-dev-server/client?http://localhost:3035 ./app/javascript/packs/application.js 40 bytes {2} [built]
webpacker_1  |   [88] ./app/javascript/packs/application.js 515 bytes {2} [built]
webpacker_1  |   [89] multi (webpack)-dev-server/client?http://localhost:3035 ./app/javascript/packs/hello_elm.js 40 bytes {0} [built]
webpacker_1  |   [90] ./app/javascript/packs/hello_elm.js 396 bytes {0} [built]
webpacker_1  |   [91] multi (webpack)-dev-server/client?http://localhost:3035 ./app/javascript/packs/Main.elm 40 bytes {1} [built]
webpacker_1  |     + 77 hidden modules
webpacker_1  | webpack: Compiled successfully.

webpacker_1  | Project is running at http://localhost:3035/
webpacker_1  | webpack output is served from /packs/
webpacker_1  | Content not from webpack is served from /app/public/packs
webpacker_1  | 404s will fallback to /index.html
webpacker_1  | Running /app/node_modules/.bin/elm-make /app/app/javascript/packs/Main.elm --yes --warn --debug --output /tmp/117813-1-1pnkvvy.kvz0s2x1or.js
webpacker_1  |  14% buiSuccess! Compiled 1 module. 17 active ...s-client/lib/transport/xdr-polling.js
webpacker_1  | Successfully generated /tmp/117813-1-1pnkvvy.kvz0s2x1or.js
webpacker_1  |
webpack 92% chunk assetHash: 0fba3c9f83d08f099017
webpacker_1  | Version: webpack 3.5.6
webpacker_1  | Time: 3705ms
webpacker_1  |                               Asset       Size  Chunks                    Chunk Names
webpacker_1  |   hello_elm-a49ad0a3ed48411416eb.js    1.87 MB       0  [emitted]  [big]  hello_elm
webpacker_1  |        Main-f0a26307d1db1882a32b.js    1.87 MB       1  [emitted]  [big]  Main
webpacker_1  | application-963cd78993444428f61c.js     896 kB       2  [emitted]  [big]  application
webpacker_1  |                       manifest.json  182 bytes          [emitted]
webpacker_1  |   [34] (webpack)-dev-server/client?http://localhost:3035 5.83 kB {0} {1} {2} [built]
webpacker_1  |   [35] ./node_modules/url/url.js 23.3 kB {0} {1} {2} [built]
webpacker_1  |   [41] ./node_modules/strip-ansi/index.js 161 bytes {0} {1} {2} [built]
webpacker_1  |   [43] ./node_modules/loglevel/lib/loglevel.js 7.74 kB {0} {1} {2} [built]
webpacker_1  |   [44] (webpack)-dev-server/client/socket.js 856 bytes {0} {1} {2} [built]
webpacker_1  |   [45] ./node_modules/sockjs-client/lib/entry.js 244 bytes {0} {1} {2} [built]
webpacker_1  |   [77] (webpack)-dev-server/client/overlay.js 3.6 kB {0} {1} {2} [built]
webpacker_1  |   [82] (webpack)/hot nonrecursive ^\.\/log$ 170 bytes {0} {1} {2} [built]
webpacker_1  |   [84] (webpack)/hot/emitter.js 77 bytes {0} {1} {2} [built]
webpacker_1  |   [86] ./app/javascript/packs/Main.elm 335 kB {0} {1} [built]
webpacker_1  |   [87] multi (webpack)-dev-server/client?http://localhost:3035 ./app/javascript/packs/application.js 40 bytes {2} [built]
webpacker_1  |   [88] ./app/javascript/packs/application.js 515 bytes {2} [built]
webpacker_1  |   [89] multi (webpack)-dev-server/client?http://localhost:3035 ./app/javascript/packs/hello_elm.js 40 bytes {0} [built]
webpacker_1  |   [90] ./app/javascript/packs/hello_elm.js 396 bytes {0} [built]
webpacker_1  |   [91] multi (webpack)-dev-server/client?http://localhost:3035 ./app/javascript/packs/Main.elm 40 bytes {1} [built]
webpacker_1  |     + 77 hidden modules
webpacker_1  | webpack: Compiled successfully.
app_1        | DEPRECATION WARNING: ActionView::Template::Handlers::Erubis is deprecated and will be removed from Rails 5.2. Switch to ActionView::Template::Handlers::ERB::Erubi instead. (called from require at /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/runtime.rb:82)
app_1        | W, [2017-09-13T15:44:45.382875 #1]  WARN -- : [SKYLIGHT] [1.3.1] Running Skylight in development mode. No data will be reported until you deploy your app.
app_1        | (To disable this message for all local apps, run `skylight disable_dev_warning`.)
app_1        | /app/app/models/test_attempts/context_test_attempt.rb:86: warning: circular argument reference - ability_estimate
app_1        | => Booting Puma
app_1        | => Rails 5.1.4 application starting in development
app_1        | => Run `rails server -h` for more startup options
app_1        | Puma starting in single mode...
app_1        | * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
app_1        | * Min threads: 5, max threads: 5
app_1        | * Environment: development
app_1        | * Listening on tcp://0.0.0.0:3000
app_1        | Use Ctrl-C to stop
app_1        | Started GET "/" for 172.18.0.1 at 2017-09-13 15:44:56 +0000
app_1        | Cannot render console from 172.18.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
app_1        |    (0.6ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
app_1        | Processing by PagesController#index as HTML
app_1        |    (0.3ms)  BEGIN
app_1        |    (0.3ms)  ROLLBACK
app_1        |   Rendering layouts/application.html.haml
app_1        |   Rendering pages/index.html.haml within layouts/application
app_1        |   Rendered pages/index.html.haml within layouts/application (78.9ms)
app_1        |   Rendered shared/_head.html.haml (37895.2ms)
app_1        |   Rendered shared/_flash.html.haml (1.0ms)
app_1        |   Rendered shared/_header.html.haml (39.9ms)
app_1        |   Rendered shared/_footer.html.haml (16.0ms)
app_1        |   Rendered shared/_analytics.html.haml (0.9ms)
app_1        |   Rendered layouts/application.html.haml (38089.9ms)
app_1        | Completed 200 OK in 38677ms (Views: 38152.2ms | ActiveRecord: 7.0ms)
app_1        |
app_1        |
app_1        | 2017-09-13 15:45:35 +0000: Rack app error handling request { GET / }
app_1        | #<Errno::EADDRNOTAVAIL: Cannot assign requested address - connect(2) for [::1]:3035>
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:1198:in `__connect_nonblock'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:1198:in `connect_nonblock'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:56:in `connect_internal'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:137:in `connect'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:627:in `block in tcp'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:227:in `each'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:227:in `foreach'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:617:in `tcp'
app_1        | /usr/local/bundle/gems/webpacker-3.0.1/lib/webpacker/dev_server.rb:9:in `running?'
app_1        | /usr/local/bundle/gems/webpacker-3.0.1/lib/webpacker/dev_server_proxy.rb:7:in `rewrite_response'
app_1        | /usr/local/bundle/gems/rack-proxy-0.6.2/lib/rack/proxy.rb:57:in `call'
app_1        | /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:522:in `call'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/configuration.rb:225:in `call'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:605:in `handle_request'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:437:in `process_client'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:301:in `block in run'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/thread_pool.rb:120:in `block in spawn_thread'
app_1        | 2017-09-13 15:45:35 +0000: Rack app error handling request { GET /favicon.ico }
app_1        | #<Errno::EADDRNOTAVAIL: Cannot assign requested address - connect(2) for [::1]:3035>
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:1198:in `__connect_nonblock'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:1198:in `connect_nonblock'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:56:in `connect_internal'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:137:in `connect'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:627:in `block in tcp'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:227:in `each'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:227:in `foreach'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:617:in `tcp'
app_1        | /usr/local/bundle/gems/webpacker-3.0.1/lib/webpacker/dev_server.rb:9:in `running?'
app_1        | /usr/local/bundle/gems/webpacker-3.0.1/lib/webpacker/dev_server_proxy.rb:7:in `rewrite_response'
app_1        | /usr/local/bundle/gems/rack-proxy-0.6.2/lib/rack/proxy.rb:57:in `call'
app_1        | /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:522:in `call'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/configuration.rb:225:in `call'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:605:in `handle_request'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:437:in `process_client'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:301:in `block in run'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/thread_pool.rb:120:in `block in spawn_thread'
app_1        | Started GET "/" for 172.18.0.1 at 2017-09-13 15:45:51 +0000
app_1        | Cannot render console from 172.18.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
app_1        | Processing by PagesController#index as HTML
app_1        |    (0.2ms)  BEGIN
app_1        |    (0.2ms)  ROLLBACK
app_1        |   Rendering layouts/application.html.haml
app_1        |   Rendering pages/index.html.haml within layouts/application
app_1        |   Rendered shared/_locked_flash.html.haml (1.2ms)
app_1        |   Rendered pages/index.html.haml within layouts/application (15.5ms)
app_1        |   Rendered shared/_head.html.haml (164.7ms)
app_1        |   Rendered shared/_flash.html.haml (1.2ms)
app_1        |   Rendered shared/_header.html.haml (20.2ms)
app_1        |   Rendered shared/_footer.html.haml (8.1ms)
app_1        |   Rendered shared/_analytics.html.haml (1.0ms)
app_1        |   Rendered layouts/application.html.haml (253.2ms)
app_1        | Completed 200 OK in 294ms (Views: 269.1ms | ActiveRecord: 5.4ms)
app_1        |
app_1        |
app_1        | 2017-09-13 15:45:51 +0000: Rack app error handling request { GET / }
app_1        | #<Errno::EADDRNOTAVAIL: Cannot assign requested address - connect(2) for [::1]:3035>
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:1198:in `__connect_nonblock'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:1198:in `connect_nonblock'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:56:in `connect_internal'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:137:in `connect'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:627:in `block in tcp'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:227:in `each'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:227:in `foreach'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:617:in `tcp'
app_1        | /usr/local/bundle/gems/webpacker-3.0.1/lib/webpacker/dev_server.rb:9:in `running?'
app_1        | /usr/local/bundle/gems/webpacker-3.0.1/lib/webpacker/dev_server_proxy.rb:7:in `rewrite_response'
app_1        | /usr/local/bundle/gems/rack-proxy-0.6.2/lib/rack/proxy.rb:57:in `call'
app_1        | /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:522:in `call'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/configuration.rb:225:in `call'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:605:in `handle_request'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:437:in `process_client'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:301:in `block in run'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/thread_pool.rb:120:in `block in spawn_thread'
app_1        | 2017-09-13 15:45:51 +0000: Rack app error handling request { GET /favicon.ico }
app_1        | #<Errno::EADDRNOTAVAIL: Cannot assign requested address - connect(2) for [::1]:3035>
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:1198:in `__connect_nonblock'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:1198:in `connect_nonblock'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:56:in `connect_internal'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:137:in `connect'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:627:in `block in tcp'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:227:in `each'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:227:in `foreach'
app_1        | /usr/local/lib/ruby/2.4.0/socket.rb:617:in `tcp'
app_1        | /usr/local/bundle/gems/webpacker-3.0.1/lib/webpacker/dev_server.rb:9:in `running?'
app_1        | /usr/local/bundle/gems/webpacker-3.0.1/lib/webpacker/dev_server_proxy.rb:7:in `rewrite_response'
app_1        | /usr/local/bundle/gems/rack-proxy-0.6.2/lib/rack/proxy.rb:57:in `call'
app_1        | /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:522:in `call'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/configuration.rb:225:in `call'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:605:in `handle_request'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:437:in `process_client'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:301:in `block in run'
app_1        | /usr/local/bundle/gems/puma-3.10.0/lib/puma/thread_pool.rb:120:in `block in spawn_thread'

这是实际网页上显示的错误输出:

Puma caught this error: Cannot assign requested address - connect(2) for [::1]:3035 (Errno::EADDRNOTAVAIL)
/usr/local/lib/ruby/2.4.0/socket.rb:1198:in `__connect_nonblock'
/usr/local/lib/ruby/2.4.0/socket.rb:1198:in `connect_nonblock'
/usr/local/lib/ruby/2.4.0/socket.rb:56:in `connect_internal'
/usr/local/lib/ruby/2.4.0/socket.rb:137:in `connect'
/usr/local/lib/ruby/2.4.0/socket.rb:627:in `block in tcp'
/usr/local/lib/ruby/2.4.0/socket.rb:227:in `each'
/usr/local/lib/ruby/2.4.0/socket.rb:227:in `foreach'
/usr/local/lib/ruby/2.4.0/socket.rb:617:in `tcp'
/usr/local/bundle/gems/webpacker-3.0.1/lib/webpacker/dev_server.rb:9:in `running?'
/usr/local/bundle/gems/webpacker-3.0.1/lib/webpacker/dev_server_proxy.rb:7:in `rewrite_response'
/usr/local/bundle/gems/rack-proxy-0.6.2/lib/rack/proxy.rb:57:in `call'
/usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:522:in `call'
/usr/local/bundle/gems/puma-3.10.0/lib/puma/configuration.rb:225:in `call'
/usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:605:in `handle_request'
/usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:437:in `process_client'
/usr/local/bundle/gems/puma-3.10.0/lib/puma/server.rb:301:in `block in run'
/usr/local/bundle/gems/puma-3.10.0/lib/puma/thread_pool.rb:120:in `block in spawn_thread'

您需要设置传递给 webpack-dev-server--listen-host 值。

您可以通过编辑文件 config/webpacker.yml 并将 development:dev_server:host: 值从 localhost 更改为 0.0.0.0 来实现此目的,这应该可以解决问题。