Shared memory between container - docker-compose

I am trying to share memory between two containers by making container A’s memory shareable and allowing container B to access it.

This works outside of balena if I start the containers individually and use the following commands.

docker run --privileged --network host --ipc:shareable containerA
docker run --privileged --network host --ipc:container:<id_of_containerA> containerB

However, when I now try to start this with the following docker-compose.yml in a Balena application, container B does not start and only gives the status “downloaded”.

version: '2'
volumes:
    resin-data:
services:
  containerA:
    restart: always
    build: ./containerA_dir
    network_mode: host
    ipc: "shareable"
    privileged: true

  containerB:
    restart: always
    build: ./containerB_dir
    network_mode: host
    ipc: "service:containerA"
    privileged: true

The documentation of balena directs me to the one of docker for the “ipc” flag, which says that the docker-compose should be working the same way as the regular docker commands.

The only difference between the two commands and the docker-compose would be the “service:containername” part which I think needs to be done, since I don’t know the container ID in advance.

Do you have any ideas what this could be or where I should look?

Hi there - looking at the docs (Docker run reference | Docker Documentation), it seems you should be able to use ipc: "container:containerA" in your docker compose for containerB. Where does it say that you must use the container id only, or have to substitute container to service?

Alternatively, does ipc: "host" satisfy your use case?

Hi @eike, did you have a chance to read my colleague’s message? Have you tried ipc: "host" or the other method?

Let us know how it went. If you are still having troubles, it’d be good to check the device logs to look for the root cause.

Yes the ipc: "host" satisfy the needs for now. It would only be nice with the specified container to gain some control over the container. We will test it and report back.

But thank you for your help