Shared Memory with Docker containers (docker version 1.4.1)

走远了吗. 提交于 2020-01-09 07:38:08

问题


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


回答1:


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 ?



来源:https://stackoverflow.com/questions/29173193/shared-memory-with-docker-containers-docker-version-1-4-1

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