# Anyone using Docker?

**URL:** https://discourse.nodered.org/t/anyone-using-docker/4208
**Category:** General
**Created:** [23 October 2018 07:45 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208 "2018-10-23T07:45:10Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![oywino](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oywino/32/26457_2.png) [@oywino](https://discourse.nodered.org/u/oywino)
#### Post date: [12 August 2020 13:25 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/21 "2020-08-12T13:25:01Z")

</div>

Let me explain what I am trying to achieve, then perhaps you may choose to be a bit more helpful?  
I am tyring to use the _Exec node_ to run the following command to update NR:

`npm install -g --unsafe-perm node-red`

But of course it fails, as the user _node-red_ does not have access to _/etc_ and its subdirectories.  
I know there's plenty alternative ways to update NR, that's not my point. I'm using this as an exercise to learn. You are most welcome to contribute to my learning.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [12 August 2020 14:30 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/22 "2020-08-12T14:30:38Z")

</div>

Personally when using docker I always use the watchtower container to monitor and update all my other containers including Node-RED.

---

<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: [12 August 2020 15:03 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/23 "2020-08-12T15:03:57Z")

</div>

Sorry, I misunderstood, I thought you wanted access to directories outside the container. I am afraid I have no idea how you can do that from node red inside Docker. Docker isn't normally used like that. This page includes details on the usual way of updating the node red version in Docker. [https://nodered.org/docs/getting-started/docker](https://nodered.org/docs/getting-started/docker).

---

<div class="post-metadata">

### Author: ![oywino](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oywino/32/26457_2.png) [@oywino](https://discourse.nodered.org/u/oywino)
#### Post date: [12 August 2020 15:32 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/24 "2020-08-12T15:32:40Z")

</div>

I don't know why I continously fail to make myself clear : I'm not trying to update NR. I know how to do that.  
I'm just using the update command as an example in order to learn how to handle (achieve) access rights.  
So please do not tell me how to update NR, tell me how to obtain elevated privileges for the user account _node-red_

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [12 August 2020 15:47 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/25 "2020-08-12T15:47:53Z")

</div>

> [@oywino](#):
>
> Let me explain what I am trying to achieve, then perhaps you may choose to be a bit more helpful?  
> I am tyring to use the _Exec node_ to run the following command to update NR:
> 
> `npm install -g --unsafe-perm node-red`

To be fair, @oywino, this post makes it sound pretty much like you are trying to upgrade Node-RED within the docker container. It isn't clear that you are using that as an example of a command to run and your actual goal is to run things with root access.

I don't know how familiar you are with linux in general, so my apologies if you already know this and have tried it, but you would use the `sudo` command to run a command with more privileges than your current user. For example:

```auto
sudo npm install -g --unsafe-perm node-red

```

That would normally prompt you for your user password, but you can config it to allow your user to run certain commands with sudo, without having to enter your password by editing the sudoers file. Does that give you enough to go read up on `sudo` and see where it gets you?

---

<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: [12 August 2020 15:50 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/26 "2020-08-12T15:50:01Z")

</div>

@knolleary, Can sudo be used within a docker container?

---

<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: [12 August 2020 15:52 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/27 "2020-08-12T15:52:23Z")

</div>

> [@oywino](#):
>
> tell me how to obtain elevated privileges for the user account _node-red_

Can you clarify whether you are trying to do things within the container that need elevated rights, or you want to run things outside the container (such as writing to /etc in the main file system of the machine).

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [12 August 2020 15:54 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/28 "2020-08-12T15:54:25Z")

</div>

> [@Colin](#):
>
> Can sudo be used within a docker container?

Ooops - I always forget that bit. You are right, by default `sudo` is not installed in the base image and would have to be installed first.

Sorry @oywino, led you down the wrong path there.

So if upgrading node-red isn't your goal, what would you like to do with the increased privileges? It may just be easier to create your own custom Docker image that does whatever it is you want.

---

<div class="post-metadata">

### Author: ![oywino](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oywino/32/26457_2.png) [@oywino](https://discourse.nodered.org/u/oywino)
#### Post date: [12 August 2020 16:34 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/29 "2020-08-12T16:34:10Z")

</div>

That's ok (even I make mistakes) 🙃  
As far as I know - since _apt-get_ isn't available either, there's no easy way to get _sudo_ installed. I was wondering about _chown_ but I'm no Linux CLI expert.  
All I want is to figure out how to give user _node-red_ write access to _/etc_ (recursively) inside the container.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [12 August 2020 16:39 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/30 "2020-08-12T16:39:27Z")

</div>

As the saying goes. “If you are trying to get there I wouldn’t start from here”. We use a two stage build to create the container. So we build it then strip out bits that aren’t normally needed to save space. Like all the build tools, apt, etc.  
If you want to do want you want to do you would be better building your own container from scratch.

---

<div class="post-metadata">

### Author: ![oywino](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oywino/32/26457_2.png) [@oywino](https://discourse.nodered.org/u/oywino)
#### Post date: [12 August 2020 18:16 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/31 "2020-08-12T18:16:13Z")

</div>

Well, I appreciate your advice, but to me it sounds like; "If I need another door between the kitchen and my living room, it's better to burn down the whole house and build a new house from scratch - with the desired number of doors (?)"  
That sounds like overkill from my perspective.  
There must be an easier way to control access rights (even though neither of us seem to know how).

Perhaps someone else knows, who happen to read this post?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [12 August 2020 18:32 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/32 "2020-08-12T18:32:14Z")

</div>

You can keep asking and maybe someone else will have a different answer to the people who actually created and maintain the container.

The container has been built to run Node-RED. That is it's primary purpose. To do that does not require write access to /etc. If you can describe why you need that level of access, it may be easier to suggest something.

Your house analogy isn't really appropriate.

We provide a default house. We also provide the tools for you to easily build you own house with whatever custom features you want.

In most cases, the default house is all that's needed. But at some point, adding one line to the dockerfile and building your own is going to be far easier.

---

<div class="post-metadata">

### Author: ![oywino](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oywino/32/26457_2.png) [@oywino](https://discourse.nodered.org/u/oywino)
#### Post date: [12 August 2020 19:27 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/33 "2020-08-12T19:27:17Z")

</div>

Please don't misunderstand me - I do really appreciate your assistance, And I agree with your logic.  
I can see where you are going by questioning my objectives. Let me put it this way; The whole thing began when I stumbled across this post:

[https://discourse.nodered.org/t/edit-displays-if-a-new-node-red-update-is-available-online-and-update-it-from-the-dashboard](https://discourse.nodered.org/t/edit-displays-if-a-new-node-red-update-is-available-online-and-update-it-from-the-dashboard)

And quickly discovered that the "project" failed when NR was installed as a container. Then I began investigating why (again - just for the learning experience).  
I did post my question in that thread too - but with no response.  
I still have a distinct feeling that there must be an easy way around this issue. Perhaps by adding user _node-red_ to the _root_ group during deployment (or something like that).

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [12 August 2020 20:18 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/34 "2020-08-12T20:18:32Z")

</div>

The easy way is to use a tool like watchtower... That is designed for exactly this job.

---

<div class="post-metadata">

### Author: ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)
#### Post date: [12 August 2020 20:21 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/35 "2020-08-12T20:21:03Z")

</div>

> [@oywino](#):
>
> As far as I know - since _apt-get_ isn't available either, there's no easy way to get _sudo_ installed.

Here below the contents of my node-red dockerfile which installs sudo.

```auto
FROM nodered/node-red:1.0.4-12

######### Changing to root as below commands should be run as root #############

USER root

# Following command installs node-red-admin which is needed if you want to create a hashed password 
# for the node-red editor. For that run command "node-red-admin hash-pw" in a terminal window
# for the node-red service in the BalenaCloud dashboard.
RUN npm install -g --unsafe-perm node-red-admin

# installing sudo command
RUN set -ex && apk --no-cache add sudo sqlite

# following commands should assure that user node-red can use sudo without requiring to enter a password.
RUN echo "node-red ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

######### Changing back to node-red user #####################
USER node-red

#RUN npm install --unsafe-perm node-red-node-sqlite

COPY settings.js entrypoint.sh ./

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

```

---

<div class="post-metadata">

### Author: ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)
#### Post date: [13 August 2020 00:59 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/36 "2020-08-13T00:59:32Z")

</div>

Hang on - so are you saying that you want the instance of NR running in the container to have additional privileges on the host it is running on.

If that is the case this is usually handled by passing in the UUID and GUID that it will map to on the host system.

You would have to look at the docker build script to see if there are options that are accepted - and if they are not you could fork of a seperate build and update the docker compose process to accept these.

I suppose you could try (although i never have) to pass in the root user and group IDs - i usually create a Linux user with the privileges where i want and then use that to run the specific container.

Craig

---

<div class="post-metadata">

### Author: ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)
#### Post date: [13 August 2020 01:04 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/37 "2020-08-13T01:04:05Z")

</div>

And here is an example of one with the enviornment they pass in and the compose file

> **[linuxserver/docker-qbittorrent](https://github.com/linuxserver/docker-qbittorrent)**
>
> Contribute to linuxserver/docker-qbittorrent development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![oywino](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oywino/32/26457_2.png) [@oywino](https://discourse.nodered.org/u/oywino)
#### Post date: [13 August 2020 05:27 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/38 "2020-08-13T05:27:36Z")

</div>

No, I do not want the instance running in the container to have additional privileges on the host system.

I want the _node-red_ user to have additional privileges inside the container.  
That, I assume - should be less of a challenge, or... ?

---

<div class="post-metadata">

### Author: ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)
#### Post date: [13 August 2020 06:29 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/39 "2020-08-13T06:29:25Z")

</div>

> [@oywino](#):
>
> I want the _node-red_ user to have additional privileges inside the container.

See my previous comment. That dockerfile gives `sudo` rights to the node-red user.  
Isn't that sufficient ?

---

<div class="post-metadata">

### Author: ![oywino](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oywino/32/26457_2.png) [@oywino](https://discourse.nodered.org/u/oywino)
#### Post date: [13 August 2020 06:57 UTC](https://discourse.nodered.org/t/anyone-using-docker/4208/40 "2020-08-13T06:57:27Z")

</div>

Yes, I just haven't gotten around to try it yet, but thank you.  
I just wanted to correct Craigs misinterpretation of my objective.

[Previous page](https://discourse.nodered.org/t/anyone-using-docker/4208.md?page=1)

[Next page](https://discourse.nodered.org/t/anyone-using-docker/4208.md?page=3)
