# Node Red Docker - New File as Root

**URL:** <https://discourse.nodered.org/t/node-red-docker-new-file-as-root/33209>\
**Category:** General\
**Created:** [23 September 2020 05:29 UTC](https://discourse.nodered.org/t/node-red-docker-new-file-as-root/33209 "2020-09-23T05:29:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paulf007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paulf007/32/26758_2.png) [@Paulf007](https://discourse.nodered.org/u/Paulf007)\
**Post date:** [23 September 2020 05:29 UTC](https://discourse.nodered.org/t/node-red-docker-new-file-as-root/33209/1 "2020-09-23T05:29:45Z")

</div>

I am creating a .txt file within node red that is running in a Docker Container. (Default settings apart from having a external folder linked to the container. )  
The file is created with a simple inject and all of that is working well but the created file's Owner is root and that creates problems if I would like external access to the file.

Is there a way to set Node Red as a local user instead of root within Docker?

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [23 September 2020 06:15 UTC](https://discourse.nodered.org/t/node-red-docker-new-file-as-root/33209/2 "2020-09-23T06:15:03Z")

</div>

You could possibly change the file ownership from within the container. Running something `chown uid:gid filename` (using an exec node) and using the UID and GID numbers of your normal user account on the system. This is if the NR user within Docker is a root account.

Otherwise you could try changing the permission to be readable/writable by all users: `chmod a+rwx file` (also using an exec node).

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 September 2020 08:34 UTC](https://discourse.nodered.org/t/node-red-docker-new-file-as-root/33209/3 "2020-09-23T08:34:59Z")

</div>

If you just need to read the files then I think if you change the access mode of the directories /var/lib/docker and /var/lib/docker/volumes to 755 then you should be able to read files in the docker volumes, if that is what you are trying to do.

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [23 September 2020 18:57 UTC](https://discourse.nodered.org/t/node-red-docker-new-file-as-root/33209/4 "2020-09-23T18:57:27Z")

</div>

@Paulf007 mentioned external folder linked to the container so I assumed he's using volume mounts to host file system dirs.

---

<div class="post-metadata">

**Author:** ![Paulf007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paulf007/32/26758_2.png) [@Paulf007](https://discourse.nodered.org/u/Paulf007)\
**Post date:** [24 September 2020 01:32 UTC](https://discourse.nodered.org/t/node-red-docker-new-file-as-root/33209/5 "2020-09-24T01:32:14Z")

</div>

Yes , that is correct.  
I have played with the following command within node red

```auto
chown -R 1000:1000 /mydata

```

and that seems to do the trick. I will still play with it a bit more to make sure all is working well.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 November 2020 01:32 UTC](https://discourse.nodered.org/t/node-red-docker-new-file-as-root/33209/6 "2020-11-23T01:32:18Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
