通过boot2docker安装到macos x文件系统的docker容器文件夹中的命名管道 [英] Named pipes in docker container folder mounted to mac os x file system through boot2docker

查看:69
本文介绍了通过boot2docker安装到macos x文件系统的docker容器文件夹中的命名管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Mac OS X上的boot2docker通过docker image包装一些科学软件.该软件( https://github.com/voutcn/megahit.git )使用命名管道(在python代码中,但这并不重要)将不同部分(用C编写)相互连接.我从主机Mac OS X机器上安装了临时文件夹,以在docker容器中提供临时区域(因为软件的临时输出可能很大),如下所示:

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)

在容器中运行时,在这个名为管道创建的已安装文件夹中,该文件夹失败.它甚至与python,C或任何特定语言都不相关.我在此文件夹中使用linux命令 mkfifo pipe1 仔细检查了一个错误:

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:以下是我为轻松重现此问题所做的操作.

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

1)带有boot2docker的Mac OS X

1) Mac OS X with boot2docker

2)Dockerfile是:

2) Dockerfile is:

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

3)建立图像:

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

4)运行(位于要挂载的外部主机文件夹中):

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

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

推荐答案

升级到适用于Mac的Docker的最新版本,您的问题将很可能得到解决:

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

问题是FIFO实际上是您使用文件系统访问的内核对象,因此您需要额外的工作来支持跨内核FIFO(或Unix域套接字)-FIFO在运行docker的Linux guest虚拟机中有效守护程序或OS X主机中的一个,而不是两者都存在,这是有道理的,您不能从linux盒子内部创建OS X fifo.这有点像试图在网络驱动器上创建一个fifo,这作为本地IPC机制没有意义.

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.

https://中详细介绍了当前对特殊文件的支持.docs.docker.com/docker-for-mac/osxfs/#file-types

跨系统管理程序支持的问题位于 https://github.com/docker/for-mac/issues/483

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

这篇关于通过boot2docker安装到macos x文件系统的docker容器文件夹中的命名管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆