Introduction
I have a demo Electron app which runs fine when running npm run start from my Mac.
I'm interested in moving the application into a Docker container, but when docker-compose reaches the electron command step, I get the following:
...
> electron --no-sandbox .
/Users/presslertj/WebstormProjects/electron-frontend/node_modules/electron/dist/electron exited with signal SIGTRAP
electron_1 | npm ERR! code ELIFECYCLE
electron_1 | npm ERR! errno 1
electron_1 | npm ERR! electron-frontend#1.0.0 start: `electron --no-sandbox .`
electron_1 | npm ERR! Exit status 1
electron_1 | npm ERR!
electron_1 | npm ERR! Failed at the electron-frontend#1.0.0 start script.
electron_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
electron_1 |
electron_1 | npm ERR! A complete log of this run can be found in:
electron_1 | npm ERR! /home/electron/.npm/_logs/2021-03-12T21_35_03_623Z-debug.log
Files
/home/electron/.npm/_logs/2021-03-12T21_35_03_623Z-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'start' ]
2 info using npm#6.14.11
3 info using node#v14.16.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle electron-frontend#1.0.0~prestart: electron-frontend#1.0.0
6 info lifecycle electron-frontend#1.0.0~start: electron-frontend#1.0.0
7 verbose lifecycle electron-frontend#1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle electron-frontend#1.0.0~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/presslertj/WebstormProjects/electron-frontend/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle electron-frontend#1.0.0~start: CWD: /Users/presslertj/WebstormProjects/electron-frontend
10 silly lifecycle electron-frontend#1.0.0~start: Args: [ '-c', 'electron --no-sandbox .' ]
11 silly lifecycle electron-frontend#1.0.0~start: Returned: code: 1 signal: null
12 info lifecycle electron-frontend#1.0.0~start: Failed to exec start script
13 verbose stack Error: electron-frontend#1.0.0 start: `electron --no-sandbox .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1048:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid electron-frontend#1.0.0
15 verbose cwd /Users/presslertj/WebstormProjects/electron-frontend
16 verbose Linux 4.19.121-linuxkit
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "start"
18 verbose node v14.16.0
19 verbose npm v6.14.11
20 error code ELIFECYCLE
21 error errno 1
22 error electron-frontend#1.0.0 start: `electron --no-sandbox .`
22 error Exit status 1
23 error Failed at the electron-frontend#1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
docker-compose.yml
version: "3.9"
services:
electron:
image: docker-image-electron_v3:latest
user: electron
environment:
- DISPLAY=host.docker.internal:0
ports:
- "50051:50051"
volumes:
- "${PWD}:${PWD}"
- "/tmp/.X11-unix:/tmp/.X11-unix"
- "./docker-logs:/home/electron/.npm/_logs"
working_dir: ${PWD}
command: >
sh -c "
npm init -y &&
npm install &&
npm run start"
here's the Dockerfile for docker-image-electron_v3 which is referenced in the docker-compose.yml:
FROM centos:latest
RUN useradd -ms /bin/bash electron
RUN dnf install -y \
alsa-lib \
at-spi2-atk \
atk \
gdk-pixbuf2 \
gtk3 \
libdrm \
libxshmfence \
mesa-libgbm \
nss
RUN dnf module install -y nodejs:14
RUN mkdir -p /home/electron/.npm
RUN chown -R 1000:1000 "/home/electron/.npm"
Software Version Info
electron = v12.0.1
docker = 20.10.2
docker-compose = 1.27.4
Questions
What is causing the electron process to fail and how can I fix it?
Is running electron from a container even a reasonable thing to do? To me it seems like an obvious and good idea but the fact that I am having a difficult way paving forward makes me very nervous
Related
After upgrading from Node 14.15 => 16.18.1, I have started getting a Error: EACCES: permission denied, scandir '/root/.npm/_logs' error when trying to run ESLint in the GitHub Actions CI/CD workflow.
Note: I am running this inside a Docker container. I am able to run the ESLint script locally in a container built from the same image, but when running in Github Actions, the workflow fails with the following error:
Creating csps-lint ... done
Attaching to csps-lint
csps-lint |
csps-lint | > lint
csps-lint | > bash ./scripts/lint.sh
csps-lint |
csps-lint | Running Prettier to identify code formatting issues...
csps-lint |
csps-lint | Checking formatting...
csps-lint | All matched files use Prettier code style!
csps-lint |
csps-lint | Running ESLint to identify code quality issues...
csps-lint | npm WARN logfile Error: EACCES: permission denied, scandir '/root/.npm/_logs'
csps-lint | npm WARN logfile error cleaning log files [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
csps-lint | npm WARN logfile errno: -13,
csps-lint | npm WARN logfile code: 'EACCES',
csps-lint | npm WARN logfile syscall: 'scandir',
csps-lint | npm WARN logfile path: '/root/.npm/_logs'
csps-lint | npm WARN logfile }
csps-lint | npm ERR! code EACCES
csps-lint | npm ERR! syscall mkdir
csps-lint | npm ERR! path /root/.npm/_cacache/tmp
csps-lint | npm ERR! errno -13
csps-lint | npm ERR!
csps-lint | npm ERR! Your cache folder contains root-owned files, due to a bug in
csps-lint | npm ERR! previous versions of npm which has since been addressed.
csps-lint | npm ERR!
csps-lint | npm ERR! To permanently fix this problem, please run:
csps-lint | npm ERR! sudo chown -R 1001:123 "/root/.npm"
csps-lint |
csps-lint | npm ERR! Log files were not written due to an error writing to the directory: /root/.npm/_logs
csps-lint | npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
csps-lint | ESLint found code quality issues. Please address any errors above and try again.
csps-lint |
csps-lint exited with code 1
1
Aborting on container exit...
Error: Process completed with exit code 1.
My GH Actions workflow is this:
name: test-eslint-fix
on:
push:
branches:
- eslint-fix
jobs:
login:
runs-on: ubuntu-latest
steps:
- uses: docker/login-action#v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
linting:
needs: login
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- run: LINT_COMMAND=lint docker-compose -f docker-comp-lint.yml up --abort-on-container-
Here is the Dockerfile that the image is created from:
# start FROM a base layer of node v16.18.1
FROM node:16.18.1
# confirm installation
RUN node -v
RUN npm -v
# Globally install webpack in the container for webpack dev server
RUN npm install webpack -g
# Install db-migrate
RUN npm install db-migrate#0.11.11 -g
# Set up a WORKDIR for application in the container
WORKDIR /usr/src/app
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json /usr/src/app/
# npm install to create node_modules in the container
RUN npm install
# EXPOSE your server port
EXPOSE 3000
This is my docker-compose file:
version: '3'
services:
csps-lint:
image: <<my image>>
container_name: csps-lint
ports:
- '3002:3002'
volumes:
- ./:/usr/src/app
- node_modules:/usr/src/app/node_modules
environment:
- NODE_ENV=test
- LINT_COMMAND=${LINT_COMMAND}
command: npm run ${LINT_COMMAND}
volumes:
node_modules:
And this is the bash script that is running the ESLint command:
# Run Prettier in check mode and store status
echo -e "\033[1;33mRunning Prettier to identify code formatting issues...\033[0m\n"
prettier --check .
PRETTIER_STATUS=$?
# Run ESLint in check mode and store status
echo -e "\n\033[1;33mRunning ESLint to identify code quality issues...\033[0m"
npx eslint .
ESLINT_STATUS=$?
I have tried adding the recommended fix from the error message in multiple places, but nothing seems to resolve the issue. I've put this command in the lint.sh script, I've added it to the Dockerfile, I've tried adding in the docker-compose file as well, but I'm unable to resolve the issue no matter where I place the command.
sudo chown -R 1001:123 "/root/.npm"
In a few of the instances, there was no access to sudo, so I'm wondering if I somehow need to install that first? Do I even need to be setting these permissions? Is there something that has changed from Node v14 to Node v16 that I'm just overlooking?
I've tried to use the solutions provided in other posts with similar error messages for other packages, but none of the solutions seem to fix this issue.
I feel like there must just be some very small thing I've missed, but the part that I'm really lost on is that I haven't changed this workflow other than upgrading the Node.js version in the Dockerfile. Also, I am able to run this workflow locally without issue in a container created from the same image, but inside GH Actions I can't seem to get past this flow.
When running the following command locally docker exec csps-lint ls -la /root/.npm/_logs, this is my output:
total 1080
drwxr-xr-x 1 root root 4096 Dec 2 23:02 .
drwxr-xr-x 1 root root 4096 Dec 2 20:15 ..
-rw-r--r-- 1 root root 1589 Nov 15 06:46 2022-11-15T06_46_44_197Z-debug-0.log
-rw-r--r-- 1 root root 1589 Dec 2 20:15 2022-12-02T20_15_05_450Z-debug-0.log
-rw-r--r-- 1 root root 65102 Dec 2 20:15 2022-12-02T20_15_05_684Z-debug-0.log
-rw-r--r-- 1 root root 59037 Dec 2 20:15 2022-12-02T20_15_09_141Z-debug-0.log
-rw-r--r-- 1 root root 943351 Dec 2 20:15 2022-12-02T20_15_14_433Z-debug-0.log
-rw-r--r-- 1 root root 1706 Dec 2 20:23 2022-12-02T20_23_05_075Z-debug-0.log
-rw-r--r-- 1 root root 1756 Dec 2 20:23 2022-12-02T20_23_16_787Z-debug-0.log
-rw-r--r-- 1 root root 1599 Dec 2 23:02 2022-12-02T23_02_23_793Z-debug-0.log
UPDATE: So I have discovered that when I run the script in the csps-lint folder locally, the user is root, but when it is run in the CI/CD, it runs as an unnamed user with ID 1001. I'm really unclear why the user would be different when the container is built from the same image no matter where it's being run.
I believe this issue was caused by npm updates no longer running in root. After much back and forth and trying 101 different things, I was able to resolve the issue by:
Adding the following command to the end of my dockerfile
RUN chown -R node:node /usr/src/app
Adding a user key to my docker-compose.yml file
version: '3'
services:
csps-lint:
image: <<my image>>
user: node
container_name: csps-lint
ports:
- '3002:3002'
volumes:
- ./:/usr/src/app
- node_modules:/usr/src/app/node_modules
environment:
- NODE_ENV=test
- LINT_COMMAND=${LINT_COMMAND}
command: npm run ${LINT_COMMAND}
volumes:
node_modules:
While installing hadoop 3.2 with docker, I encounter the following error:
Setting up npm (3.5.2-0ubuntu4) ...
Processing triggers for libc-bin (2.23-0ubuntu11.2) ...
WARN engine npm#7.13.0: wanted: {"node":">=10"} (current: {"node":"4.2.6","npm":"3.5.2"})
WARN engine npm#7.13.0: wanted: {"node":">=10"} (current: {"node":"4.2.6","npm":"3.5.2"})
/usr/local/lib
`-- (empty)
npm ERR! Linux 4.15.0-29-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "npm#latest" "-g"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! path /usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552' -> '/usr/local/lib/node_modules/npm/node_modules/#npmcli/ci-detect'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552' -> '/usr/local/lib/node_modules/npm/node_modules/#npmcli/ci-detect'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /root/npm-debug.log
npm ERR! code 1
How can I solve this problem?
The bash script, supplied with Hadoop 3.2 source file and contains the docker commands, is as follows:
#!/usr/bin/env bash
set -e # exit on error
cd "$(dirname "$0")" # connect to root
docker build -t hadoop-build dev-support/docker
if [ "$(uname -s)" = "Linux" ]; then
USER_NAME=${SUDO_USER:=$USER}
USER_ID=$(id -u "${USER_NAME}")
GROUP_ID=$(id -g "${USER_NAME}")
# man docker-run
# When using SELinux, mounted directories may not be accessible
# to the container. To work around this, with Docker prior to 1.7
# one needs to run the "chcon -Rt svirt_sandbox_file_t" command on
# the directories. With Docker 1.7 and later the z mount option
# does this automatically.
if command -v selinuxenabled >/dev/null && selinuxenabled; then
DCKR_VER=$(docker -v|
awk '$1 == "Docker" && $2 == "version" {split($3,ver,".");print ver[1]"."ver[2]}')
DCKR_MAJ=${DCKR_VER%.*}
DCKR_MIN=${DCKR_VER#*.}
if [ "${DCKR_MAJ}" -eq 1 ] && [ "${DCKR_MIN}" -ge 7 ] ||
[ "${DCKR_MAJ}" -gt 1 ]; then
V_OPTS=:z
else
for d in "${PWD}" "${HOME}/.m2"; do
ctx=$(stat --printf='%C' "$d"|cut -d':' -f3)
if [ "$ctx" != svirt_sandbox_file_t ] && [ "$ctx" != container_file_t ]; then
printf 'INFO: SELinux is enabled.\n'
printf '\tMounted %s may not be accessible to the container.\n' "$d"
printf 'INFO: If so, on the host, run the following command:\n'
printf '\t# chcon -Rt svirt_sandbox_file_t %s\n' "$d"
fi
done
fi
fi
else # boot2docker uid and gid
USER_NAME=$USER
USER_ID=1000
GROUP_ID=50
fi
docker build -t "hadoop-build-${USER_ID}" - <<UserSpecificDocker
FROM hadoop-build
RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}
RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME}
RUN echo "${USER_NAME} ALL=NOPASSWD: ALL" > "/etc/sudoers.d/hadoop-build-${USER_ID}"
ENV HOME /home/${USER_NAME}
UserSpecificDocker
#If this env varible is empty, docker will be started
# in non interactive mode
DOCKER_INTERACTIVE_RUN=${DOCKER_INTERACTIVE_RUN-"-i -t"}
# By mapping the .m2 directory you can do an mvn install from
# within the container and use the result on your normal
# system. And this also is a significant speedup in subsequent
# builds because the dependencies are downloaded only once.
docker run --rm=true $DOCKER_INTERACTIVE_RUN \
-v "${PWD}:/home/${USER_NAME}/hadoop${V_OPTS:-}" \
-w "/home/${USER_NAME}/hadoop" \
-v "${HOME}/.m2:/home/${USER_NAME}/.m2${V_OPTS:-}" \
-u "${USER_ID}" \
"hadoop-build-${USER_ID}" "$#"
and I used the following command to run the file:
sudo ./start-build-env.sh
Edit: tried to install hadoop with marven over two days, but I have problem installing the pre-existing packages, and don't know what do about it. Thus I tried the docker version, which consider to be easier, but it does not works...
Windows 10 Pro
Docker for Windows
I'm following a tutorial that should allow me to build and deploy a simple Vue.js application via Docker. I'm able to deploy the Django app as my backend and access via port 8000, but the frontend deployment fails. To be more specific, the frontend is built and then exits seconds later. Logs/Commands below
UPDATE:
I migrated to Linux and haven't looked back since. No problems in an Ubuntu environment. Docker for Windows might still need some work.
Docker log:
Recreating frontend ... done Attaching to db, backend, frontend
frontend | Cache verified and compressed (~/.npm/_cacache):
frontend | Content verified: 0 (0 bytes)
frontend | Index entries: 0
frontend | Finished in 0.027s
frontend | npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules/fsevents):
frontend | npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
frontend |
frontend | audited 928740 packages in 26.389s
frontend | found 1 high severity vulnerability
frontend | run `npm audit fix` to fix them, or `npm audit` for details
frontend |
frontend | > code#0.1.0 serve /app
frontend | > vue-cli-service serve
frontend |
frontend | /app/node_modules/.bin/vue-cli-service: line 1: XSym: not found
frontend | /app/node_modules/.bin/vue-cli-service: line 2: 0042: not found
frontend | /app/node_modules/.bin/vue-cli-service: line 3: 9b6d22955dddeb6cfbc52c6ade7b03d0: not found
frontend | /app/node_modules/.bin/vue-cli-service: line 4: ../#vue/cli-service/bin/vue-cli-service.js: not found
frontend | npm ERR! code ELIFECYCLE
frontend | npm ERR! syscall spawn
frontend | npm ERR! file sh
frontend | npm ERR! errno ENOENT
frontend | npm ERR! code#0.1.0 serve: `vue-cli-service serve`
frontend | npm ERR! spawn ENOENT
frontend | npm ERR!
frontend | npm ERR! Failed at the code#0.1.0 serve script.
frontend | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
frontend |
frontend | npm ERR! A complete log of this run can be found in:
frontend | npm ERR! /root/.npm/_logs/2019-10-25T14_05_55_326Z-debug.log
frontend exited with code 1
npm ERR! complete log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'serve' ]
2 info using npm#6.11.3
3 info using node#v12.12.0
4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
5 info lifecycle code#0.1.0~preserve: code#0.1.0
6 info lifecycle code#0.1.0~serve: code#0.1.0
7 verbose lifecycle code#0.1.0~serve: unsafe-perm in lifecycle true
8 verbose lifecycle code#0.1.0~serve: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/app/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle code#0.1.0~serve: CWD: /app
10 silly lifecycle code#0.1.0~serve: Args: [ '-c', 'vue-cli-service serve' ]
11 info lifecycle code#0.1.0~serve: Failed to exec serve script
12 verbose stack Error: code#0.1.0 serve: `vue-cli-service serve`
12 verbose stack spawn ENOENT
12 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack at ChildProcess.emit (events.js:210:5)
12 verbose stack at maybeClose (internal/child_process.js:1021:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
13 verbose pkgid code#0.1.0
14 verbose cwd /app
15 verbose Linux 4.9.184-linuxkit
16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "serve"
17 verbose node v12.12.0
18 verbose npm v6.11.3
19 error code ELIFECYCLE
20 error syscall spawn
21 error file sh
22 error errno ENOENT
23 error code#0.1.0 serve: `vue-cli-service serve`
23 error spawn ENOENT
24 error Failed at the code#0.1.0 serve script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
Frontend project creation commands:
# docker run --rm -it -v ~/dockerproject/frontend:/code node:12.12.0-alpine /bin/sh
# cd code
# npm i -g vue #vue/cli
# vue create .
Vue Project creation prompt:
Vue CLI v4.0.4
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, PWA, Router, Vuex, CSS Pre-processors, Linter, Unit, E2E
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with dart-sass)
? Pick a linter / formatter config: Airbnb
? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection)Lint on save
? Pick a unit testing solution: Jest
? Pick a E2E testing solution: Nightwatch
? Pick browsers to run end-to-end test on Chrome, Firefox
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In package.json
? Save this as a preset for future projects? No
? Pick the package manager to use when installing dependencies: NPM
Docker-compose Build command:
docker-compose -f docker-compose.yml up --build
Project Folder:
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/24/2019 4:41 PM backend
d----- 10/24/2019 3:53 PM env
d----- 10/25/2019 7:33 AM frontend
d----- 10/25/2019 9:05 AM npmlogs
-a---- 10/25/2019 8:58 AM 674 docker-compose.dev.yml
-a---- 10/24/2019 3:53 PM 242 docker-compose.yml
-a---- 10/23/2019 10:07 AM 52 README.md
frontend folder:
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/25/2019 7:19 AM node_modules
d----- 10/25/2019 7:13 AM public
d----- 10/25/2019 7:13 AM src
d----- 10/25/2019 7:13 AM tests
-a---- 10/25/2019 7:13 AM 160 .editorconfig
-a---- 10/25/2019 7:21 AM 326 .gitignore
-a---- 10/25/2019 7:22 AM 75 .gitkeep
-a---- 10/25/2019 7:15 AM 76 babel.config.js
-a---- 10/25/2019 7:26 AM 272 Dockerfile
-a---- 10/25/2019 7:15 AM 577145 package-lock.json
-a---- 10/25/2019 7:13 AM 1745 package.json
-a---- 10/25/2019 7:15 AM 423 README.md
-a---- 10/25/2019 7:33 AM 152 start_dev.sh
Dockerfile in frontend folder:
FROM node:12.12.0-alpine
# make the 'app' folder the current working directory
WORKDIR /app/
# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .
# expose port 8080 to the host
EXPOSE 8080
CMD ["sh", "start_dev.sh"]
start_dev.sh in frontend folder:
#!/bin/bash
# https://docs.npmjs.com/cli/cache
npm cache verify
# install project dependencies
npm install
# run the development server
npm run serve
Docker-compose file in root folder:
version: '3'
services:
db:
container_name: db
image: postgres
networks:
- main
backend:
container_name: backend
build: ./backend
command: /start.sh
volumes:
- .:/code
ports:
- "8000:8000"
networks:
- main
depends_on:
- db
frontend:
container_name: frontend
build:
context: ./frontend
volumes:
- ./frontend:/app/frontend:ro
- '/app/node_modules'
- ./npmlogs:/root/.npm/_logs/
ports:
- "8080:8080"
networks:
- main
depends_on:
- backend
- db
environment:
- NODE_ENV=development
networks:
main:
driver: bridge
I tried for so many hours now and tried so many things that I have to ask now.
On my docker I can't get nodered to run on it. I get permissions error for the shared volume all the time. My other container for "fhem" does run with the same folder permissions. So i don't get why its a problem for nodered.
Currently I'm using ubuntu on the latest version.
I want to store the /data folder from the nodered instance in /opt/docker-nodered but this doesn't work.
I tried to install it with the following command:
docker run -it -p 1880:1880 -v /opt/docker-nodered/:/data --name nodered nodered/node-red-docker
The permissions here are the following:
stefmde#homeautomation:/opt$ ll
total 16
drwxr-xr-x 4 stefmde stefmde 4096 Sep 24 09:52 ./
drwxr-xr-x 23 root root 4096 Sep 21 18:56 ../
drwxr-xr-x 10 stefmde stefmde 4096 Sep 22 12:48 docker-fhem/
drwxr-xr-x 2 stefmde stefmde 4096 Sep 24 14:01 docker-nodered/
I changed them with the following to try to get it running:
chown -R stefmde:stefmde /opt/docker-nored
But no mather what I try, I always get the same error:
stefmde#homeautomation:/opt/docker-nodered$ sudo docker run -it -p 1880:1880 -v /opt/docker-nodered/:/data --name nod ered nodered/node-red-docker
> node-red-docker#1.0.0 start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"
fs.js:642
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES: permission denied, open '/data/settings.js'
at Error (native)
at Object.fs.openSync (fs.js:642:18)
at copyFileFallback (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:93:18)
at copyFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:85:10)
at onFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:58:12)
at getStats (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:51:39)
at startCopy (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:41:10)
at Object.copySync (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:36:10)
at Object.<anonymous> (/usr/src/node-red/node_modules/node-red/red.js:104:20)
at Module._compile (module.js:577:32)
npm ERR! Linux 4.15.0-34-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" "--" "--userDir" "/data"
npm ERR! node v6.14.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! node-red-docker#1.0.0 start: `node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-red-docker#1.0.0 start script 'node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-red-docker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-red-docker
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-red-docker
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /usr/src/node-red/npm-debug.log
The npm.debug.log-file doesn't exist
I tried different permission sets, I checked the UUID which is 1000 of my user, I tried to run "npm install" manually, checked different bug tickets on github, tried the "--User"-Flag which isn't working, running the docker command with and without "sudo" and so on.
Please can someone try to help me or tell me what i did wrong?
I hope you could :)
The node-red docker container runs as the user node-red, a lot of other docker containers run the application as the default user, which happens to be root.
At the moment your docker-nodered directory is only writable by the user stefmde and root (because root can write to anywhere)
The quick solution is to make the docker-nodered writable by anybody (chmod o+w docker-nodered) this should work.
The longer solution will be to work out what the UID of the node-red user is, add a group to the host OS that has a member with the same UID as node-red and make the directory owned by that group and then make it group writable (chmod g+w docker-nodered)
EDIT: The default uid:gid for the node-red user is 1000:1000
By far, the easiest method is to change ownership of the Node-RED data folder to user 1000 and group 1000, as this is hard-coded in the Node-RED docker container:
sudo chown 1000:1000 name-of-node-red-data-folder
I've workaround that worked for me using docker-compose. I've created the file docker-compose-node-red.yml with the following content:
version: "3.7"
services:
node-red:
image: nodered/node-red:latest
ports:
- "1880:1880"
volumes:
- "/path/to/a-nodered-project:/data"
Then, I run
$ docker-compose -f docker-compose-node-red.yml up
In the folder /path/to/a-nodered-project I have a flows.json file and others. Everything is accessible from the node-red container perspective.
I have followed the following tut:
https://docs.nativescript.org/tutorial/chapter-1#11-creating-apps
to create the demo app hello world, only when Im trying to run the last command in the cli:
npm run build-ios-bundle -- --release --copy-to HalloWorld.ipa
Builds the project for iOS and produces an APP or IPA that you can manually deploy in the iOS Simulator or on device, respectively.
IMPORTANT: Before building for iOS device, verify that you have configured a valid pair of certificate and provisioning profile on your OS X system.
Options
child process exited with code 127
npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/Cellar/node/7.9.0/bin/node" "/usr/local/bin/npm" "run" "ns-bundle" "--ios" "--build-app" "--release" "--copy-to" "HalloWorld.ipa"
npm ERR! node v7.9.0
npm ERR! npm v4.2.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! # ns-bundle: ns-bundle "HalloWorld.ipa"
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the # ns-bundle script 'ns-bundle "HalloWorld.ipa"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ns-bundle "HalloWorld.ipa"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Hugo/.npm/_logs/2017-04-12T14_47_59_306Z-debug.log
npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/Cellar/node/7.9.0/bin/node" "/usr/local/bin/npm" "run" "build-ios-bundle" "--" "--release" "--copy-to" "HalloWorld.ipa"
npm ERR! node v7.9.0
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # build-ios-bundle: npm run ns-bundle --ios --build-app "--release" "--copy-to" "HalloWorld.ipa"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # build-ios-bundle script 'npm run ns-bundle --ios --build-app "--release" "--copy-to" "HalloWorld.ipa"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run ns-bundle --ios --build-app "--release" "--copy-to" "HalloWorld.ipa"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Hugo/.npm/_logs/2017-04-12T14_47_59_349Z-debug.log
Debug log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/7.9.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build-ios-bundle',
1 verbose cli '--',
1 verbose cli '--release',
1 verbose cli '--copy-to',
1 verbose cli 'HalloWorld.ipa' ]
2 info using npm#4.2.0
3 info using node#v7.9.0
4 verbose run-script [ 'prebuild-ios-bundle',
4 verbose run-script 'build-ios-bundle',
4 verbose run-script 'postbuild-ios-bundle' ]
5 info lifecycle #~prebuild-ios-bundle: #
6 silly lifecycle #~prebuild-ios-bundle: no script for prebuild-ios-bundle, continuing
7 info lifecycle #~build-ios-bundle: #
8 verbose lifecycle #~build-ios-bundle: unsafe-perm in lifecycle true
9 verbose lifecycle #~build-ios-bundle: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/Hugo/Desktop/HelloWorld/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
10 verbose lifecycle #~build-ios-bundle: CWD: /Users/Hugo/Desktop/HelloWorld
11 silly lifecycle #~build-ios-bundle: Args: [ '-c',
11 silly lifecycle 'npm run ns-bundle --ios --build-app "--release" "--copy-to" "HalloWorld.ipa"' ]
12 silly lifecycle #~build-ios-bundle: Returned: code: 1 signal: null
13 info lifecycle #~build-ios-bundle: Failed to exec build-ios-bundle script
14 verbose stack Error: # build-ios-bundle: `npm run ns-bundle --ios --build-app "--release" "--copy-to" "HalloWorld.ipa"`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:194:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:194:7)
14 verbose stack at maybeClose (internal/child_process.js:899:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid #
16 verbose cwd /Users/Hugo/Desktop/HelloWorld
17 error Darwin 16.0.0
18 error argv "/usr/local/Cellar/node/7.9.0/bin/node" "/usr/local/bin/npm" "run" "build-ios-bundle" "--" "--release" "--copy-to" "HalloWorld.ipa"
19 error node v7.9.0
20 error npm v4.2.0
21 error code ELIFECYCLE
22 error errno 1
23 error # build-ios-bundle: `npm run ns-bundle --ios --build-app "--release" "--copy-to" "HalloWorld.ipa"`
23 error Exit status 1
24 error Failed at the # build-ios-bundle script 'npm run ns-bundle --ios --build-app "--release" "--copy-to" "HalloWorld.ipa"'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error npm run ns-bundle --ios --build-app "--release" "--copy-to" "HalloWorld.ipa"
24 error You can get information on how to open an issue for this project with:
24 error npm bugs
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]
Can you please help me,
Regards,
I just had the same issue, switching back to node 6.11 works fine.