Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 625
rsutormin Avatar asked Nov 19 '15 22:11

rsutormin


People also ask

Where are Dockerfiles stored Mac?

On a Mac, the default location for Docker images is ~/Library/Containers/com. docker.

Can Docker containers run on both Windows and Mac operating systems?

You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.

Does a Docker container have a MAC address?

By default, the MAC address is generated using the IP address allocated to the container. You can set the container's MAC address explicitly by providing a MAC address via the --mac-address parameter (format: 12:34:56:78:9a:bc ).Be aware that Docker does not check if manually specified MAC addresses are unique.

What is docker0 used for?

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.


1 Answers

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

like image 140
Roee Shenberg Avatar answered Oct 13 '22 01:10

Roee Shenberg