# sharing value between containers

**URL:** <https://forums.balena.io/t/sharing-value-between-containers/367750>\
**Category:** Project help\
**Created:** [April 21, 2023, 11:56am UTC](https://forums.balena.io/t/sharing-value-between-containers/367750 "2023-04-21T11:56:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://forums.balena.io/u/Hugo)\
**Post date:** [April 21, 2023, 11:56am UTC](https://forums.balena.io/t/sharing-value-between-containers/367750/1 "2023-04-21T11:56:29Z")

</div>

Hello everyone,

I’m trying to share value between 2 python files in 2 differents containers, the idea is to use “volume” so both .py can access the file. On .py will fill the .txt file and the other will read the .txt file. When I try to upload it there is an error: “Bind mounts are not allowed”. How can I fix it ? Am I using the containers in the right way ? Attached the folder that I try to flash, my dockercompose and the two dockerfile. Notice that in the folder “writer” and “reader” there is the python file and the docker file.

Thank you in advance for the help.

Hugo.  
 ![docker_compose](https://global.discourse-cdn.com/balena/original/2X/b/ba037d28c6388d49374c6d65e4ce0d5e5857d247.png)

 ![folder](https://global.discourse-cdn.com/balena/original/2X/7/769424aa22ad91cbf48e3da4ad98b441d079de70.png)  
 ![dockerfile](https://global.discourse-cdn.com/balena/original/2X/6/633b83a64253340805968365dabc0f01637fa276.png)

---

<div class="post-metadata">

**Author:** ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://forums.balena.io/u/Hugo)\
**Post date:** [April 26, 2023, 1:56am UTC](https://forums.balena.io/t/sharing-value-between-containers/367750/2 "2023-04-26T01:56:46Z")

</div>

Still searching for help. Even short advice. If you can help me let me know.

Thank you.

Hugo

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [April 26, 2023, 9:36am UTC](https://forums.balena.io/t/sharing-value-between-containers/367750/4 "2023-04-26T09:36:38Z")

</div>

Hello @Hugo thank you for your message.

Actually we don’t support bind mounts at balena (yet). You can read more about the docker-compose on balena here [Multiple containers - Balena Documentation](https://docs.balena.io/learn/develop/multicontainer/#docker-composeyml-file)

My recommendation would be to copy these exact files on the image at the right location from the Dockerfile.

Let us know if this works for you!

---

<div class="post-metadata">

**Author:** ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://forums.balena.io/u/Hugo)\
**Post date:** [April 27, 2023, 8:53am UTC](https://forums.balena.io/t/sharing-value-between-containers/367750/6 "2023-04-27T08:53:01Z")

</div>

Hello mpous,

Thank you for your help. Does it mean that I don’t use the “volume” and I just copy the file in the directory from the Dockerfile ? Is there any other way to share variable between containers that I have to try?

---

<div class="post-metadata">

**Author:** ![alanb128](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/alanb128/32/2839_2.png) [@alanb128](https://forums.balena.io/u/alanb128)\
**Post date:** [April 28, 2023, 1:31am UTC](https://forums.balena.io/t/sharing-value-between-containers/367750/7 "2023-04-28T01:31:03Z")

</div>

Hello @hugo, you can still use volumes (but not bind mounted) to share files among containers. See [Multiple containers - Balena Documentation](https://docs.balena.io/learn/develop/multicontainer/#named-volumes) and also an example here of volumes being shared among various services: [coral-audio-analysis/docker-compose.yml at master · balena-io-experimental/coral-audio-analysis · GitHub](https://github.com/balena-io-experimental/coral-audio-analysis/blob/master/docker-compose.yml)  
Another way you could share variables or data is to use a database that has an API that each Python service can access. Redis is a popular choice for this use case, and has an easy API.  
[https://redis.io/](https://redis.io/)  
[Redis with Python | Redis Documentation Center](https://docs.redis.com/latest/rs/references/client_references/client_python/)
