Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

group id not set in docker-custom/Dockerfile.custom (v1.1.3) #203

Open
johndsheehan opened this issue Oct 8, 2020 · 2 comments
Open

group id not set in docker-custom/Dockerfile.custom (v1.1.3) #203

johndsheehan opened this issue Oct 8, 2020 · 2 comments

Comments

@johndsheehan
Copy link

Hi, in docker-custom/Dockerfile.custom no group id is created or assigned to the user node-red. It defaults to the root group. This creates permission problems when running something like,

docker run  --rm  --user=$UID  -it -p 1880:1880 -v /home/user/.node-red:/data  --name mynodered nodered/node-red

as the permissions in the host directory /home/user/.node-red, become mangled.

Adding something like the following seems to address it,

: xps 0 %; git diff
diff --git a/docker-custom/Dockerfile.custom b/docker-custom/Dockerfile.custom
index 018648e..c084498 100644
--- a/docker-custom/Dockerfile.custom
+++ b/docker-custom/Dockerfile.custom
@@ -21,11 +21,10 @@ RUN set -ex && \
         openssh-client && \
     mkdir -p /usr/src/node-red /data && \
     deluser --remove-home node && \
-    adduser -h /usr/src/node-red -D -H node-red -u 1000 && \
-    chown -R node-red:root /data && chmod -R g+rwX /data && \ 
-    chown -R node-red:root /usr/src/node-red && chmod -R g+rwX /usr/src/node-red
-    # chown -R node-red:node-red /data && \
-    # chown -R node-red:node-red /usr/src/node-red
+    addgroup  --gid 1001  node-red  && \
+    adduser -h /usr/src/node-red -D -H node-red  -u 1001  -G node-red  && \
+    chown -R node-red:node-red /data && \
+    chown -R node-red:node-red /usr/src/node-red
 
 # Set work directory
 WORKDIR /usr/src/node-red

@ErikMinekus
Copy link

I have the same issue with 1.2.7. When I map /data to a volume, the container fails to start:

nodered_1  | > [email protected] start /usr/src/node-red
nodered_1  | > node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"
nodered_1  |
nodered_1  | fs.js:114
nodered_1  |     throw err;
nodered_1  |     ^
nodered_1  |
nodered_1  | Error: EACCES: permission denied, copyfile '/usr/src/node-red/node_modules/node-red/settings.js' -> '/data/settings.js'
nodered_1  |     at Object.copyFileSync (fs.js:1728:3)
nodered_1  |     at copyFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:68:8)
nodered_1  |     at onFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:53:25)
nodered_1  |     at getStats (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:48:44)
nodered_1  |     at startCopy (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
nodered_1  |     at handleFilterAndCopy (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:33:10)
nodered_1  |     at Object.copySync (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:26:10)
nodered_1  |     at Object.<anonymous> (/usr/src/node-red/node_modules/node-red/red.js:125:20)
nodered_1  |     at Module._compile (internal/modules/cjs/loader.js:778:30)
nodered_1  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
nodered_1  | npm ERR! code ELIFECYCLE
nodered_1  | npm ERR! errno 1
nodered_1  | npm ERR! [email protected] start: `node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"`
nodered_1  | npm ERR! Exit status 1
nodered_1  | npm ERR!
nodered_1  | npm ERR! Failed at the [email protected] start script.
nodered_1  | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

The permissions for the host directory are root:root, which I assume should be node-red:node-red.

@meknipp
Copy link

meknipp commented Aug 18, 2024

I was able to work around this issue by adding user: root to my docker-compose for node-red to force the container to run under root on the host.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants