首页 > 解决方案 > 从 docker 容器共享 unix 套接字到 ubuntu 主机

问题描述

您好,我正在尝试从我的 docker 容器 rails 应用程序共享一个 unix 套接字到我的 ubuntu 主机,以便将 puma 服务器与 nginx 反向代理连接。

在我的 docker-compose 文件中,我有:

version: '3.2'

services:
  web:
    command: puma -b 'unix:///var/run/puma.sock?umask=0777'
    ports:
      - '3000:3000'
    volumes:
      - /var/run/puma.sock:/var/run/puma.sock:rw

加载卷时,我在 Web 服务上收到此错误:

web_1       | * Listening on unix:///var/run/puma.sock?umask=0777
web_1       | /usr/local/bundle/gems/puma-3.9.1/lib/puma/binder.rb:359:in `unlink': Is a directory @ unlink_internal - /var/run/puma.sock (Errno::EISDIR)
web_1       |   from /usr/local/bundle/gems/puma-3.9.1/lib/puma/binder.rb:359:in `rescue in add_unix_listener'
web_1       |   from /usr/local/bundle/gems/puma-3.9.1/lib/puma/binder.rb:356:in `add_unix_listener'
web_1       |   from /usr/local/bundle/gems/puma-3.9.1/lib/puma/binder.rb:141:in `block in parse'
web_1       |   from /usr/local/bundle/gems/puma-3.9.1/lib/puma/binder.rb:88:in `each'
web_1       |   from /usr/local/bundle/gems/puma-3.9.1/lib/puma/binder.rb:88:in `parse'
web_1       |   from /usr/local/bundle/gems/puma-3.9.1/lib/puma/runner.rb:144:in `load_and_bind'
web_1       |   from /usr/local/bundle/gems/puma-3.9.1/lib/puma/single.rb:87:in `run'
web_1       |   from /usr/local/bundle/gems/puma-3.9.1/lib/puma/launcher.rb:174:in `run'
web_1       |   from /usr/local/bundle/gems/puma-3.9.1/lib/puma/cli.rb:77:in `run'
web_1       |   from /usr/local/bundle/gems/puma-3.9.1/bin/puma:10:in `<top (required)>'
web_1       |   from /usr/local/bundle/bin/puma:23:in `load'
web_1       |   from /usr/local/bundle/bin/puma:23:in `<main>'

我期待这种行为:

web_1    | Puma starting in single mode...
web_1    | * Version 3.9.1 (ruby 2.3.7-p456), codename: Private Caller
web_1    | * Min threads: 5, max threads: 5
web_1    | * Environment: production
web_1    | I, [2018-12-08T15:10:17.371560 #1]  INFO -- sentry: ** [Raven] Raven 2.7.4 ready to catch errors
web_1    | I, [2018-12-08T15:10:17.686838 #1]  INFO -- : Raven 2.7.4 ready to catch errors
web_1    | * Listening on unix:///var/run/puma.sock?umask=0777
web_1    | Use Ctrl-C to stop

仅当我使用卷时才会出现错误。你能帮我个忙吗?

标签: ruby-on-railsdockerpuma

解决方案


推荐阅读