I want to communicate between two docker containers using shared memory. In both containers, a simple C program is running.
I tried this example and it works very well: Shared Memory with Docker containers (docker version 1.4.1)
However, when I create a new shared memory area, the Shared-Memory-ID is always "0". I already tried to using a key generated via ftok()
and also using the key IPC_PRIVATE
:
key_t key = ftok("shmfile", 65);
int shmid = shmget(key, 1024, IPC_CREAT | 0666);
printf("%d \n", shmid);
void *shmdata = shmat(shmid, NULL, 0);
I expect that the ID won't always be 0 and that it will be different when a different key is used.