Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
585 views
in Technique[技术] by (71.8m points)

ipc - Shared Memory with Docker containers (docker version 1.4.1)

I have 1 process that writes to a specific section of shared memory (i.e. "/falcon" )in a docker container.

Docker image: dockersharedmemory/shmclient

I have another process that initially creates and reads the same section of shared memory(i.e. "/falcon" ) every second in another docker container.

Docker image: dockersharedmemory/shmserver

When I run the two containers using the following commands I am able to read and write in each container respectfully:

docker run -d -v /dev:/dev dockersharedmemory/shmserver

docker run -d -v /dev:/dev dockersharedmemory/shmclient

When I use the "--ipc" option per documentation i can't get it to work:

docker run -d --ipc=host dockersharedmemory/shmserver

docker run -d --ipc=host dockersharedmemory/shmclient

neither

docker run -d dockersharedmemory/shmserver

drunk_feynman

docker run -d --ipc=container:drunk_feynman dockersharedmemory/shmclient

happy_fermi

Client version: 1.4.1
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): 5bc2ff8/1.4.1
OS/Arch (client): linux/amd64
Server version: 1.4.1
Server API version: 1.16
Go version (server): go1.3.3
Git commit (server): 5bc2ff8/1.4.1

I have a working example now with a combination of the commands on the host by punching huge holes in the container with a combination of volumes and ipc: docker run -d -v /dev/shm:/dev/shm --ipc=host dockersharedmemory/shmserver docker run -d -v /dev/shm:/dev/shm --ipc=host dockersharedmemory/shmclient

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You still need -v /dev:/dev what happens if you do

docker run -d -v /dev:/dev --ipc=host dockersharedmemory/shmserver

docker run -d -v /dev:/dev --ipc=host dockersharedmemory/shmclient

If you dont mount bind /dev/ then the container cannot see whats inside /dev/ which is where your IPC/shm resides isnt it ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...