# Named volumes are created with different owner ID (100, 1000, 0)?

**URL:** <https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599>\
**Category:** balenaEngine\
**Created:** [November 7, 2019, 7:38am UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599 "2019-11-07T07:38:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/janvda/32/1271_2.png) [@janvda](https://forums.balena.io/u/janvda)\
**Post date:** [November 7, 2019, 7:38am UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599/1 "2019-11-07T07:38:23Z")

</div>

It is unclear to me how the owner ID of a named volume is set when deploying a new balena application or when purging data.

So I have named volumes where the owner ID is 100, 1000 and 0 (= root).

After purging data I see that the owner ID of the named volume has been changed from 1000 to 100 or 0.  
This is a problem as the user (ID = 1000) of my container service can no longer write to the named volume as it has a different owner ID.

An example where the owner ID = 0 (= root)

```auto
oot@4d176de:/var/lib/docker/volumes/1284969_node-red-data2# ls -l
total 4
drwxr-xr-x 2 root root 4096 Nov 7 07:24 _data

```

An example where the owner ID = 100

```auto
root@4d176de:/var/lib/docker/volumes/1284969_node-red-data# ls -l 
total 4
drwxr-xr-x 2 100 root 4096 Nov 7 07:24 _data

```

An example (of another application on another device) where the owner ID = 1000

```auto
root@ba7c427:/var/lib/docker/volumes/1481607_node_red_data# ls -l  
total 4
drwxr-xr-x 5 1000 1000 4096 Nov 7 07:14 _data

```

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/janvda/32/1271_2.png) [@janvda](https://forums.balena.io/u/janvda)\
**Post date:** [November 7, 2019, 8:09am UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599/2 "2019-11-07T08:09:37Z")

</div>

I have also seen following related post [Permission denied for persistence storage](https://forums.balena.io/t/permission-denied-for-persistence-storage/17230)

This post suggests to change the owner of the respective folder at runtime in the start script, but I am using docker image `nodered/node-red:1.0.2-12-arm32v7` and in that case it is not clear to me how I can do this ?

---

<div class="post-metadata">

**Author:** ![mikesimos](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mikesimos/32/1418_2.png) [@mikesimos](https://forums.balena.io/u/mikesimos)\
**Post date:** [November 7, 2019, 11:13am UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599/3 "2019-11-07T11:13:51Z")

</div>

Hi there!  
Can you share a Dockerfile and docker-compose file samples, reproducing the described behavior?  
Also, did you try something like this: [Permission denied for persistence storage](https://forums.balena.io/t/permission-denied-for-persistence-storage/17230/23)

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/janvda/32/1271_2.png) [@janvda](https://forums.balena.io/u/janvda)\
**Post date:** [November 7, 2019, 11:32am UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599/5 "2019-11-07T11:32:53Z")

</div>

Hi,

I haven’t tried [Permission denied for persistence storage](https://forums.balena.io/t/permission-denied-for-persistence-storage/17230/23) (in fact I don’t know how I can do that for my docker service).

My (node-red) Dockerfile and docker-compose file can be found in my github repository:

- [https://github.com/janvda/balena-kodi-etcetera](https://github.com/janvda/balena-kodi-etcetera)

kr  
Jan

---

<div class="post-metadata">

**Author:** ![mikesimos](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mikesimos/32/1418_2.png) [@mikesimos](https://forums.balena.io/u/mikesimos)\
**Post date:** [November 7, 2019, 11:54am UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599/6 "2019-11-07T11:54:57Z")

</div>

Sweet! I see there is an alpine node-red base image too 🙂 [https://github.com/node-red/node-red-docker/blob/master/.docker/Dockerfile.alpine](https://github.com/node-red/node-red-docker/blob/master/.docker/Dockerfile.alpine)  
You should be able to use that, and just use the steps defined here [Permission denied for persistence storage](https://forums.balena.io/t/permission-denied-for-persistence-storage/17230/23) . Cheers!

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/janvda/32/1271_2.png) [@janvda](https://forums.balena.io/u/janvda)\
**Post date:** [November 7, 2019, 1:31pm UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599/8 "2019-11-07T13:31:10Z")

</div>

I guess I can also add an ENTRYPOINT in my node-red docker file that is running a script that is setting the owner of the /data folder and then starts node-red (with command `npm start -- --userDir /data`)

---

<div class="post-metadata">

**Author:** ![shaunmulligan](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/shaunmulligan/32/34_2.png) [@shaunmulligan](https://forums.balena.io/u/shaunmulligan)\
**Post date:** [November 7, 2019, 1:38pm UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599/9 "2019-11-07T13:38:59Z")

</div>

Yeah, an entrypoint script might be a good way to go. Just note that some of the functionality offered from the `balenalib/` base images will be lost if you overwrite the entrypoint. Most notably the UDEV=1 feature that helps keep /dev in the container fresh as devices get plugged in or out. But depending on your usecase that might not be an issue at all.

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/janvda/32/1271_2.png) [@janvda](https://forums.balena.io/u/janvda)\
**Post date:** [November 7, 2019, 9:04pm UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599/11 "2019-11-07T21:04:01Z")

</div>

Thanks for the remark concerning UDEV. The service was not based on a balena lib/ base image so from that perspective my entrypoint solution doesn’t change anything.

FYI the details of the solution:  
1/ I have fixed it by adding the following lines to my [node-red Dockerfile](https://github.com/janvda/balena-kodi-etcetera/blob/master/node-red/Dockerfile):

```auto
COPY ./entrypoint.sh .

# the below entrypoint replaces the entrypoint of the nodered/node-red
ENTRYPOINT ["bash", "entrypoint.sh"]

```

2/ and the contents of the `entrypoint.sh` =

```auto
#!/bin/bash

echo "Allowing node-red to write to folder /data ..."
sudo chown node-red:node-red /data

echo "Starting node-red ..."
npm start -- --userDir /data

```

---

<div class="post-metadata">

**Author:** ![gelbal](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gelbal/32/1109_2.png) [@gelbal](https://forums.balena.io/u/gelbal)\
**Post date:** [November 8, 2019, 11:43am UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599/14 "2019-11-08T11:43:49Z")

</div>

Thanks for sharing your solution @janvda.

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/janvda/32/1271_2.png) [@janvda](https://forums.balena.io/u/janvda)\
**Post date:** [December 16, 2019, 11:18pm UTC](https://forums.balena.io/t/named-volumes-are-created-with-different-owner-id-100-1000-0/42599/16 "2019-12-16T23:18:20Z")

</div>

Although this solution works, it means that I should enable `sudo` in my container which actually defeats the point of running my container as a non root user.

So it would be better to have a solution that doesn’t require to enable `sudo` in order to change the UID of the named data volume.
