Named pipes in docker container folder mounted to mac os x file system through boot2docker

牧云@^-^@ 提交于 2021-01-27 04:21:49

问题


I'm working on wrapping some scientific software by docker image using boot2docker on Mac OS X. And that software (https://github.com/voutcn/megahit.git) is using named pipes (in python code, but it's not important) to wire different parts (written in C) to each other. I mount temporary folder from host Mac OS X machine to provide scratch area in docker container (because temporary output of software could be huge) with something like this:

docker run -v /external/folder:/tmp/scratch <image> <args>

It gives me this mount line inside container:

none on /tmp/scratch type vboxsf (rw,nodev,relatime)

And inside this mounted folder named pipe creation fails when it runs inside container. It's not even related to python, C or any particular language. I double checked with linux command mkfifo pipe1 in this folder with an error:

mkfifo: cannot create fifo 'pipe1': Operation not permitted

It works well for any internal not mounted folder inside container though. Why does it happen and how could it be fixed?

PS: Here is what I do to easily reproduce the problem.

1) Mac OS X with boot2docker

2) Dockerfile is:

FROM ubuntu:14.04
#WORKDIR /tmp <- this one would work
WORKDIR /tmp/scratch
ENTRYPOINT [ "mkfifo" ]
CMD [ "pipe1" ]

3) Image building:

docker build --rm -t mine/namedpipes:latest .

4) Running (being in external host folder to be mounted):

docker run -v $(pwd):/tmp/scratch mine/namedpipes:latest

回答1:


Upgrade to a recent version of Docker for Mac, and your problem will likely be solved: https://docs.docker.com/docker-for-mac/release-notes/#beta-2-release-2016-03-08-1102-beta2

The issue is that FIFOs are actually kernel objects you access using the filesystem, and so you would need extra work to support cross-kernel FIFOs (or unix domain sockets) - a fifo is either valid inside the Linux guest running the docker daemon or in the OS X host, not in both, and it makes sense that you can't create an OS X fifo from inside the linux box. It would be sort of like trying to create a fifo on a network drive, it doesn't make sense as a local IPC mechanism.

Current support for special files is detailed in https://docs.docker.com/docker-for-mac/osxfs/#file-types

The issue for cross-hypervisor support is located at https://github.com/docker/for-mac/issues/483



来源:https://stackoverflow.com/questions/33815562/named-pipes-in-docker-container-folder-mounted-to-mac-os-x-file-system-through-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!