Docker for Macでのホストとコンテナ間のUnixドメインソケット通信

  •  
  •  

Unix Domain Socketを介した通信を行うSeverとClientがあり、それに関連する開発を行っていた

ある時ローカルでServerを動かし、Clientの開発・テストはDocker上でやってみようと思い立ちやってみる

するとこんなエラーである。。。

Error: connect ECONNREFUSED /tmp/sample.sock

よく調べてみるとこんな感じ
https://docs.docker.com/docker-for-mac/osxfs/#file-types

Symlinks, hardlinks, socket files, named pipes, regular files, and directories are supported. Socket files and named pipes only transmit between containers and between macOS processes -- no transmission across the hypervisor is supported, yet. Character and block device files are not supported.

Docker Desktop for Macではホストとコンテナ間のUnixドメインソケットの共有はサポートしてないってさ。。。

ちなみにissueはコレっぽい
https://github.com/docker/for-mac/issues/483

とりあえずMacではできない。

そしてマニュアルにも書いてあるが、コンテナ同士の共有はできるので、ServerもClientもコンテナ使えばOK

ちなみに検証に使ったコードはこちら
https://github.com/gucchisk/node-samples/tree/master/unix-domain-socket

コメントする