Can docker port forward to a unix file socket on the host container?

前端 未结 2 1698
再見小時候
再見小時候 2020-12-29 23:20

Running the following command fails:

sudo docker run -p unix:///tmp/file.sock:44444 -d image_name

Is something wrong with my port forwardin

2条回答
  •  鱼传尺愫
    2020-12-29 23:56

    The accepted answer is partially correct however since you can only link directories, which means you need to link the directory of the socket instead of the socket itself.

    The following did it for me when I wanted to connect a postgres socket.

    docker run -p 5432:5432 -v /run/postgresql:/run/postgresql -d --name postgres postgres

    What this does is link the postgres socket file to your host system.

提交回复
热议问题