I am trying to setup a node.js app inside docker, using as host the google compute engine VM gci-stable-55-8872-71-0 (debian), from image project google-containers:
$ gcloud compute instances create myvm --image-project google-containers --image gci-stable-55-8872-71-0 --zone europe-west1-b --machine-type f1-micro --scopes compute-rw
then I try to get a docker container running:
$ sudo docker build -t forperfuse/test .
but I keep getting errors when installing node:
The command '/bin/sh -c npm install' returned a non-zero code: 1
all other dependencies install well but node and npm are not installing- I have tried several options but still cannot get it to work, can you please help? many thanks in advance...
I'm not sure about what is going on, looks like the run command in the dockerfile is aiming to a bash that has a weird header. If you can publish them we can try or...
You can use the bitnami docker image available in launcher for free and works like a charm.
https://console.cloud.google.com/launcher
And there search for the node.js image.
Related
I have a Nestjs Application which I try to run in a docker container. It all worked fine just until recently where I get the error Parse Error: Missing expected CR after header value. I'm trying to make a http GET Request to a webserver of an IoT device. Furthermore this error occurs only when I run the server-app inside a docker container. When I run it locally on a windows or macos machine everything works fine.
I tried using different versions of nodejs in docker. 14, 16 and 18. This error always comes up, independent of which version I use. I have no idea how I could debug this error, since it only occurs when I serve the app inside a docker container.
This is my dockerfile:
FROM node:slim
RUN mkdir -p /app
WORKDIR /app
COPY src .
COPY package.json .
RUN apt update && apt install python3 make g++ -y
RUN npm install --force
EXPOSE 3000
CMD ["npm", "run", "start:dev"]
According to this issue, this was recently implemented in Node v14.20.0, v16.16.0 and v18.5.0. Apparently it fixes a vulnerability in the HTTP parser of earlier versions.
Comments below the issue suggest various workarounds if it's not possible to fix the client, the easiest of which seems to be to set the insecureHTTPParser flag to true when creating the HTTP server.
Alternatively, revert to an older minor version of each of the Node.js versions mentioned above.
I have this Dockerfile
FROM node:14
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD [ "node", "app.mjs" ]
And I can successfully run
docker run hello-world
on my ubuntu 20.10 OS.
So I am assuming that docker is installed successfully.
But when I tried to run
docker build .
It gives me this error
This is not something with the npm. I can locally install the dependencies without any issue. I assume Dokcer can't access npm registry to pull the npm packages. Something to do with networks I guess.
How do I fix this issue?
This is my code
https://github.com/Enuri-Information-Systems/docker-test
Depending on the network configuration it could happen that you run into problems that the container is not able to connect to a server to download data. This can have various reasons and also depends on how you run docker.
One common thing is that your network requires the usage of a proxy. But only having the error message it is not possible to tell what the exact reason in your case is.
One solution to that problem is to specify the network mode. Adding --network host as an option should most of the time work.
So running your build command that way docker build --network=host . should work.
I've installed ffplay in my working folder (in bin subfolder) using ffbinaries (ffbinaries downloader). My current platform is linux-64.
I've use:
var spawn = require('child_process').spawn,
player = spawn('./bin/ffplay', ['http://path_to_video_file']);
but got an error in terminal stderr:
./bin/ffplay: error while loading shared libraries: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory child process exited with code : 127
How can I get access from my javascript code to this binary for playing videos or how can I get ready-to-use binary which is a built-in for my Electron app?
...Or how can I get all of ffplay possibilities for playing videos inside Electron app?
Thanks in advance!
The error you get means that ffplay cannot find libSDL.
First, make sure the library is installed by opening a terminal window and typing:
sudo apt install libsdl2-dev
If it wasn't installed, try to run your program again after it was installed.
If you still have the problem, type the following in your terminal window:
export LD_LIBRARY_PATH="/usr/local/lib"
Try again to run your program. If the problem is now solved, edit the file etc/environment and add the setting there to make it permanent:
sudo nano /etc/environment
Add this LD_LIBRARY_PATH="/usr/local/lib" at the end, exit and save.
Hope it helps.
Currently working on sawtooth example
Things I have done :
Installed latest Node(8.11.3)& npm version.
Started javascript
essential thing using docker-compose up.
Things giving error:
Want to setup Javascript transaction processor so moved to dir jsprocessor.
Trying to install all node modules using $ npm i, but giving error shown in image. I think it is relate to node js.
Reinstalled Node & NPM, Externally installed npm module that producing error but no effect.
What am I doing wrong?
I would follow the directions at
https://github.com/askmish/sawtooth-simplewallet
Which seems different from what you ran.
Build and start the Docker containers:
docker-compose -f simplewallet-build-client-js.yaml up
Open bash shell in simplewallet-client-js container:
docker exec -it simplewallet-client-js bash
Create user accounts for jack and jill:
sawtooth keygen jack && sawtooth keygen jill
Open two new browser tabs and go to http://localhost:3000 on each tab.
Login in one tab as jack and in other as jill Start with an initial deposit for each user - jack and jill via the Deposit tab in the UI homepage
I am able to connect to a VPN from terminal easily with the following openVPN command:
openvpn --config conf.ovpn
I need connect to the same VPN with Javascript (for selenium test), I already have installed openvpn.client with NPM:
npm install openvpn-client
However, I don't know how it works. I would like how to achieve a terminal application with similar functionalities of openvpn.
Documentation and source code
https://www.npmjs.com/package/openvpn-client
https://github.com/resin-io/openvpn-client
Solved, more or less...
After install openvpn in the system just add bit s to the openvpn bin (sudo chmod +s /usr/sbin/openvpn), then you can connect openvpn with this:
var exec = require("child_process").exec;
cmd = `openvpn --config ${conf.ovpn}&`;
exec(cmd);
Just that. Maybe isn't the most secure solution, but it works for my purpose.
Thanks.