Npm offline package installation in docker container - docker

I am trying to install node-red-contrib-influxdb in a node-red docker container that is on a computer with no way to access internet. I have a Windows computer, that I have also installed node.js on, and installed/downloaded the node-red-contrib-influxdb package and npm-pack-all.
I tried to run npm-pack-all in the node-red-contrib-influxdb install location to get all the dependencies installed (those dependencies I have installed manually as well, but this didn't help) and moved the resulting tgz file to the docker container and ran npm install on it. This results in a following error:
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/influx failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
npm ERR! A complete log of this run can be found in:
npm ERR! /usr/src/node-red/.npm/_logs/2023-01-31T14_33_13_404Z-debug.log
With the relevant lines in the log being:
15 silly resolveWithNewModule node-red-contrib-influxdb#0.6.1 checking installable status
16 silly fetchPackageMetaData error for influx#5.6.3 request to https://registry.npmjs.org/influx failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
17 timing stage:rollbackFailedOptional Completed in 19ms
18 timing stage:runTopLevelLifecycles Completed in 7103ms
19 silly saveTree node-red-project#0.0.1
19 silly saveTree +-- #influxdata/influxdb-client#1.33.1
19 silly saveTree +-- influx#5.9.3
19 silly saveTree +-- lodash#4.17.21
19 silly saveTree `-- node-red-contrib-influxdb#0.6.1
20 verbose type system
21 verbose stack FetchError: request to https://registry.npmjs.org/influx failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
21 verbose stack at ClientRequest.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
21 verbose stack at ClientRequest.emit (events.js:400:28)
21 verbose stack at TLSSocket.socketErrorListener (_http_client.js:475:9)
21 verbose stack at TLSSocket.emit (events.js:400:28)
21 verbose stack at emitErrorNT (internal/streams/destroy.js:106:8)
21 verbose stack at emitErrorCloseNT (internal/streams/destroy.js:74:3)
21 verbose stack at processTicksAndRejections (internal/process/task_queues.js:82:21)
22 verbose cwd /data
23 verbose Linux 4.4.0-cip-rt-moxa-imx7d
24 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "./node-red-contrib-influxdb-0.6.1.tgz"
25 verbose node v14.18.2
26 verbose npm v6.14.15
27 error code EAI_AGAIN
28 error errno EAI_AGAIN
29 error request to https://registry.npmjs.org/influx failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
30 verbose exit [ 1, true ]
How would I resolve this error and enable offline installation of this particular npm package?

I would approach this in a different way.
Create a custom Node-RED container by extending the existing container and then install the required nodes while building the container (on a machine with internet access) then copy the new container to your offline machine.
e.g.
FROM nodered/node-red:latest
USER root
RUN npm install node-red-contrib-influxdb
USER node-red
The USER switch is because the install will be into /usr/src/node-red which is along side Node-RED

Related

VS Code not recognizing Docker in WSL

I was previously able to run Remote Containers inside VS Code without any errors. For some unknown reason, today it stopped working with this error when I try to reopen in a container. Error is: Docker Desktop WSL 2 backend required.
In the Windows Powershell, I can see that docker is indeed installed.
PS C:\Users\Me> wsl docker --version
Docker version 20.10.14, build a224086
I tried to reinstall and follow the instructions in Docker Desktop WSL 2 backend setup.
Use WSL 2 based engine is checked
Integration with the Ubuntu distro is enabled
Inside the Ubuntu command line, I can also run docker ps with no problem at all.
It's just inside VS Code that's having issues. Here's the trace log to help out more:
[1491047 ms] Host server: Error: spawn /usr/local/bin/docker ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:477:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
[1491049 ms] Start: Run in Host: /usr/local/bin/docker version --format {{.Server.APIVersion}}
[1491049 ms] Host server: (node:3238) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)
[1491051 ms] Host server: Error: spawn /usr/local/bin/docker ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:477:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
[1491052 ms] Stop (3 ms): Run in Host: /usr/local/bin/docker version --format {{.Server.APIVersion}}
[1491052 ms] spawn /usr/local/bin/docker ENOENT

VS code terminal process failed to launch as debugging in attached running container

I'm trying to setup Airflow debugging environment with VS code using Remote - containers plugin. What I did so far:
docker-compose up the image apache/airflow:2.2.4 with Docker Desktop community 2.4 on macOS 10.13.6
Attach to the running airflow-scheduler container with Remote - containers plugin
Compose a launch.json file with
"version": "0.2.0",
"configurations": [
{
"name": "Airflow Test",
"type": "python",
"request": "launch",
// $ which airflow
"program": "/home/airflow/.local/bin/airflow",
"console": "integratedTerminal",
"args": [
"dags",
"test",
"task_of_middleware",
"2022-04-08"
],
"justMyCode": true
}
]
VS code pops up error below when I start debugging:
The terminal process failed to launch: Path to shell executable "/sbin/nologin" does not exist.
The attached running container shows error:
[1382 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd ; readlink /proc/$pid/ns/mnt ; cat /proc/$pid/stat | tr "
[1518 ms] Container server: Error: spawn /sbin/nologin ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:477:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
[1525 ms] Error: spawn /sbin/nologin ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:477:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
[1530 ms] Container server: (node:11888) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)
I think the container runs normally since I'm able to connect to container shell via Docker Desktop and run Airflow test command. Any advice would be appreciated.
Not sure if this is the best practice, I found a way to ease the error and make debugger run normally. Put a config into the Attached container configuration files by select Remote-Containers: Open Container Configuration File from the Command Palette after attaching.
// Container user VS Code should use when connecting
"remoteUser": "root"
Reference here.

Error while downloading geckodriver during webdriver-manager update from jenkins

I am trying to run webdriver update from jenkins. I am downloading geckoDriver and chromeDriver. Chrome driver is downloading and unzipping properly. But gecko driver download is not working.
However this is working fine from local. Issue occurs only in jenkins
Command used:
node_modules/protractor/bin/webdriver-manager update --ignore_ssl --proxy=http://proxy --versions.gecko=v0.25.0 --versions.chrome=78.0.3904.105
Firefox version in server: 60.9.0
Error:
[16:23:13] I/http_utils - ignoring SSL certificate
[16:23:13] I/config_source - curl -ok /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml 'http://proxy...' -H 'host:chromedriver.storage.googleapis.com'
[16:23:13] I/http_utils - ignoring SSL certificate
[16:23:13] I/config_source - curl -ok /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/gecko-response.json 'http://proxy.../repos/mozilla/geckodriver/releases' -H 'host:api.github.com'
[16:23:13] I/http_utils - ignoring SSL certificate
[16:23:14] I/downloader - curl -ok /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105.zip 'http://proxy.../78.0.3904.70/chromedriver_linux64.zip' -H 'host:chromedriver.storage.googleapis.com'
[16:23:14] I/update - chromedriver: unzipping chromedriver_78.0.3904.105.zip
[16:23:14] I/update - chromedriver: setting permissions to 0755 for /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105
[16:23:16] I/http_utils - ignoring SSL certificate
[16:23:17] E/downloader - tunneling socket could not be established, statusCode=403
[16:23:17] I/update - geckodriver: file exists /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0.tar.gz
[16:23:17] I/update - geckodriver: unzipping geckodriver-v0.25.0.tar.gz
(node:42561) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, rename '/var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver' -> '/var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0'
at Object.renameSync (fs.js:598:3)
at unzip (/var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/built/lib/cmds/update.js:240:8)
at files_1.FileManager.downloadFile.then.downloaded (/var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/built/lib/cmds/update.js:205:13)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:42561) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:42561) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
When i manually downloaded the driver files and added inside node_modules/selenium location, webdriver-manager update is successful. But the tunneling socket error was still present. Logs below:
[16:30:00] I/http_utils - ignoring SSL certificate
[16:30:00] I/http_utils - ignoring SSL certificate
[16:30:00] I/http_utils - ignoring SSL certificate
[16:30:00] I/update - chromedriver: file exists /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105.zip
[16:30:00] I/update - chromedriver: unzipping chromedriver_78.0.3904.105.zip
[16:30:00] I/update - chromedriver: setting permissions to 0755 for /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105
[16:30:00] I/update - chromedriver: chromedriver_78.0.3904.105 up to date
[16:30:02] E/downloader - tunneling socket could not be established, statusCode=403
[16:30:02] I/update - geckodriver: file exists /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0.tar.gz
[16:30:02] I/update - geckodriver: unzipping geckodriver-v0.25.0.tar.gz
[16:30:02] I/update - geckodriver: setting permissions to 0755 for /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0
[16:30:02] I/update - geckodriver: geckodriver-v0.25.0 up to date
But ng e2e is failing with the below error:
[16:30:03] I/launcher - Running 1 instances of WebDriver
[16:30:03] I/direct - Using FirefoxDriver directly...
[16:30:03] E/launcher - spawn /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0 EACCES
[16:30:03] E/launcher - Error: spawn /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0 EACCES
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
[16:30:03] E/launcher - Process exited with error code 199
npm ERR! code ELIFECYCLE
npm ERR! errno 1
I am using directconnect=true in protractor conf.js
Can someone please check what i am doing wrong here?
There are a few things that you can try here:
1) If your tests are running inside a container, you will have to disable the dev-shm usage by adding a "--disable-dev-shm-usage" flag in your capabilities. Or you can mount the dev/shm as a volume when you run your tests.
2) You can set Marionette to true in your browser capabilities for firefox.
3) Run the container as root so that it runs as a privilaged user
4) Run the tests using ./node_modules/protractor/bin/protractor protractor.conf.js instead of using ng e2e
5) Update the webdriver packages using ./node_modules/protractor/bin/webdriver-manager update --ignore_ssl --proxy=http://proxy --versions.gecko=v0.25.0 --versions.chrome=78.0.3904.105
6) Try adding these lines to your entrypoint for the docker image:
#!/bin/bash
uid=$(stat -c %u ${PWD})
gid=$(stat -c %g ${PWD})
groupadd -o -g $gid protractor
useradd -m -o -u $uid -g $gid protractor
sudo -u protractor npm run test
Still I cannot say if one of these steps would solve your problem.
I had same problem when I was doing this in a docker container. The 'tar' and 'gzip' packages weren't installed. The problem got resolved after I installed these packages.

Node API failing with Error : EHOSTUNREACH

ERRO 8dc [composerchannel][a68ccd16] failed to invoke chaincode name:"tryme" , error: Failed to generate platform-specific docker build: Error returned from build: 1 "npmERR! code EHOSTUNREACH
npm ERR! errno EHOSTUNREACH
npm ERR! request to https://registry.npmjs.org/composer-common failed, reason: connect EHOSTUNREACH 104.16.18.35:443
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-08-08T10_52_34_967Z-debug.log
I get this error on my NodeJS API, when I open docker logs I find this error was the part of Peer Container.
What I understand from this error is Hyperledger is trying to ping the URL 104.16.18.35:443, which is been blocked by my firewall as per my understanding.
But the bigger Question is If my network is internally setup then why Docker Container is trying to Ping this IP.

Setting volumes in docker-compose.yml file for windows 10 home

Trying to set up docker so that when I change my project files on my windows machine they are updated in my docker container. From this question I learned that you should use the volumes setting in the docker-compose.yml file.
But I still can't get it to work.
I have tried to set the volumes to (+30 similar combinations):
volumes:
- x
.:/home/app/angular-seed
//c/Users/k/dev/angular-seed/:/home/app/angular-seed
c/Users/k/dev/angular-seed:/home/app/angular-seed
C:/User/k/dev/angular-seed
I have also tried adding a .env file with:
COMPOSE_CONVERT_WINDOWS_PATHS=1
COMPOSE_CONVERT_WINDOWS_PATHS=0
When I do docker-compose up
and set volumes to .:/home/app/angular-seed I get:
ERROR: for angular-seed Cannot create container for service angular-seed: invalid bind mount spec "C:\\Users\\k\\dev\\angular-seed:/home/app/angular-seed:rw": invalid volume specification: 'C:\Users\k\dev\angular-seed:/home/app/angular-seed:rw' [31mERROR[0m: Encountered errors while bringing up the project.
When I set volumes to /c/Users/dev/angular-seed:/home/app/angular-seed I get: ...includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intented to pass a host directory, use absolute path.
When I set it to C:/User/k/dev/angular-seed I get ...invalid volume specification...
I have checked that Oracle VM Virtual Box Manager have shared folders (Machine Folders) set to:
c/Users \\?\c:\Users (auto mount) yes (Access) full
Other responses I have seen are everything from:
Recreating angular-seed-start
Attaching to angular-seed-start
[36mangular-seed-start |[0m npm info it worked if it ends with ok
[36mangular-seed-start |[0m npm info using npm#3.10.3
[36mangular-seed-start |[0m npm info using node#v6.6.0
[36mangular-seed-start |[0m npm info lifecycle angular-seed#0.0.0~prestart: angular-seed#0.0.0
[36mangular-seed-start |[0m npm info lifecycle angular-seed#0.0.0~start: angular-seed#0.0.0
[36mangular-seed-start |[0m
[36mangular-seed-start |[0m > angular-seed#0.0.0 start /home/app/angular-seed
[36mangular-seed-start |[0m > gulp serve.dev --color
[36mangular-seed-start |[0m
[36mangular-seed-start |[0m sh: 1: gulp: not found
[36mangular-seed-start |[0m
[36mangular-seed-start |[0m npm info lifecycle angular-seed#0.0.0~start: Failed to exec start script
[36mangular-seed-start |[0m npm ERR! Linux 4.4.43-boot2docker
[36mangular-seed-start |[0m npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
to
[31mERROR[0m: Named volume "c/Users/k/dev/angular-seed:/home/app/angular- seed:rw" is used in service "angular-seed" but no declaration was found in the volumes section.
to
Recreating 90b0444c8ee3_90b0444c8ee3_90b0444c8ee3_90b0444c8ee3_angular-seed-start
ERROR: for angular-seed Cannot create container for service angular-seed: invalid bind mount spec "C:\\Users\\k\\dev\\angular-seed\\dev\\angular-seed:/home/app/angular-seed:rw": invalid volume specification: 'C:\Users\k\dev\angular-seed\dev\angular-seed:/home/app/angular-seed:rw'
[31mERROR[0m: Encountered errors while bringing up the project.
to
Recreating 90b0444c8ee3_90b0444c8ee3_90b0444c8ee3_angular-seed-start
ERROR: for angular-seed Cannot create container for service angular-seed: create \c\Users\k\dev\angular-seed: "\\c\\Users\\k\\dev\\angular-seed" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intented to pass a host directory, use absolute path
[31mERROR[0m: Encountered errors while bringing up the project.
Try these lines in your docker-compose.yml file:
volumes:
- /c/Users/k/dev/angular-seed:/home/app/angular-seed

Resources