All Questions
6,307
questions
287
votes
20
answers
221k
views
Docker-compose: node_modules not present in a volume after npm install succeeds
I have an app with the following services:
web/ - holds and runs a python 3 flask web server on port 5000. Uses sqlite3.
worker/ - has an index.js file which is a worker for a queue. the web server ...
188
votes
27
answers
150k
views
How to install nvm in docker?
I am in the process of building a new Docker image and I'm looking to get NVM installed so I can manage nodejs.
Reading the docs on how to install NVM they mention that you need to source your ....
159
votes
5
answers
170k
views
How to cache the RUN npm install instruction when docker build a Dockerfile
I am currently developing a Node backend for my application.
When dockerizing it (docker build .) the longest phase is the RUN npm install. The RUN npm install instruction runs on every small server ...
150
votes
11
answers
321k
views
npm WARN old lockfile The package-lock.json file was created with an old version of npm
I have a dockerfile as shown below, and when i execute it, I get a warning that i can't figure out in the RUN npm ci step:
npm WARN old lockfile The package-lock.json file was created with an old ...
108
votes
17
answers
173k
views
How to set npm credentials using `npm login` without reading from stdin?
I'm trying to automate npm publish inside a Docker container, but I receive an error when the npm login command tries to read the username and email:
npm login << EOF
username
password
email
EOF
...
97
votes
5
answers
122k
views
Docker: Uses an image, skipping (docker-compose)
I am currently trying out this tutorial for node express with mongodb
https://medium.com/@sunnykay/docker-development-workflow-node-express-mongo-4bb3b1f7eb1e
the first part works fine where to build ...
97
votes
8
answers
134k
views
ECONNREFUSED for Postgres on nodeJS with dockers
I'm building an app running on NodeJS using postgresql.
I'm using SequelizeJS as ORM.
To avoid using real postgres daemon and having nodejs on my own device, i'm using containers with docker-compose.
...
93
votes
8
answers
186k
views
Use docker run command to pass arguments to CMD in Dockerfile
I have a nodejs app can take two parameters when started. For example, I can use
node server.js 0 dev
or
node server.js 1 prod
to switch between production mode and dev mode and determine if it ...
90
votes
13
answers
243k
views
Install node in Dockerfile?
I am user of AWS elastic beanstalk, and I have a little problem. I want to build my CSS files with less+node. But I don`t know how to install node in my dockerfile, when building with jenkins.
Here ...
85
votes
11
answers
187k
views
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in /app/node_modules/@babel/helper-compilation-targets/package.json
I'm having trouble building my nuxt images in a travis CI pipeline. My local environment is ubuntu 18.04 - docker version 19.03.11 docker-compose version 1.24.1 I'm able to build and run my images ...
79
votes
8
answers
99k
views
Docker Node Alpine Image Build Fails on node-gyp
I'm attempting to Dockerize a Vue.js application. I'm using the node:10.15-alpine Docker image as a base. The image build fails with the following error:
gyp ERR! configure error
gyp ERR! stack Error:...
79
votes
5
answers
77k
views
Running app inside Docker as non-root user
After yesterday's news of Shocker, it seems like apps inside a Docker container should not be run as root. I tried to update my Dockerfile to create an app user however changing permissions on app ...
72
votes
9
answers
230k
views
Cannot find module for a node js app running in a docker compose environment
I am sorry for my very newbie question, but I am having a terrible day figuring out this error, I have an Express app and I am trying to run it in docker compose.
I've used this Dockerfile:
FROM ...
67
votes
1
answer
59k
views
Docker HTTP-requests between containers
I'm at the first stage in learning how to use Docker so I'm trying basic things. I've created two Node Express services that need to exchange data via HTTP-requests.
My docker-compose.yml file
...
66
votes
6
answers
86k
views
How do I access a server on localhost with nginx docker container?
I'm trying to use a dockerized version of nginx as a proxy server for my node (ExpressJS) application. Without any configuration to nginx and publishing port 80 for the container, I am able to see the ...
63
votes
4
answers
100k
views
How to execute a shell command before the ENTRYPOINT via the dockerfile
I have the following file for my nodejs project
FROM node:boron
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN ...
61
votes
7
answers
33k
views
'exec user process caused: exec format error' in AWS Fargate Service
I am totally new to AWS but I've been running my dockerized application locally for months now with no issues. Now that I am trying to deploy this app via AWS ECS/Fargate, my containers are stopped ...
59
votes
3
answers
33k
views
Jenkins. Invalid agent type "docker" specified. Must be one of [any, label, none]
My JenkinsFile looks like:
pipeline {
agent {
docker {
image 'node:12.16.2'
args '-p 3000:3000'
}
}
stages {
stage('Build') {
...
57
votes
4
answers
21k
views
How to build a docker image from a nodejs project in a monorepo with yarn workspaces
We are currently looking into CI/CD with our team for our website. We recently also adapted to a monorepo structure as this keeps our dependencies and overview a lot easier. Currently testing etc is ...
50
votes
3
answers
16k
views
Should I use forever/pm2 within a (Docker) container?
I am refactoring a couple of node.js services. All of them used to start with forever on virtual servers, if the process crashed they just relaunch.
Now, moving to containerised and state-less ...
44
votes
2
answers
16k
views
Kubernetes equivalent of `docker run --init`
It is a recommended best practice to not run dockerized Node.JS applications as PID 1 (see https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#handling-kernel-signals) in order to ...
43
votes
5
answers
46k
views
connecting to local mongodb from docker container
I have a local mongoDB server running on mongodb://127.0.0.1:27017. My DB name is localv2. I have a node/express app with the Dockerfile as follows:
FROM node:7.5
RUN npm install -g pm2
RUN mkdir -...
43
votes
3
answers
14k
views
Why COPY package*.json ./ precedes COPY . .?
In this Node.js tutorial on Docker:
https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
What is the point of COPY package*.json ./?
Isn't everything copied over with COPY . .?
The Dockerfile in ...
39
votes
5
answers
62k
views
Docker mongo image 'Connection refused' from other container
I'm new to docker. I'm trying to create a MongoDB container and a NodeJS container. My file looks:
version: '2'
services:
backend:
image: node:5.11-onbuild
ports:
- "3001:3001"
...
39
votes
5
answers
20k
views
Nodemon Doesn't Restart in Windows Docker Environment
My goal is to set up a Docker container that automatically restarts a NodeJS server when file changes are detected from the host machine.
I have chosen nodemon to watch the files for changes.
On ...
38
votes
4
answers
71k
views
Connecting to mongo docker container from host
I'm running Docker on OS X with:
docker run --name mongo -p 27017:27017 -v ./data/db:/data/db -d mongo mongod
and using the ip I get from:
docker inspect --format '{{ .NetworkSettings.IPAddress }}' ...
38
votes
5
answers
43k
views
Speed up NPM install in Docker container
We use the standard practices of not including node_modules in version control. However, when moving through the CI/CD pipeline, we have to reinstall NPM dependencies in several places and it makes ...
38
votes
8
answers
22k
views
Why is COPY in docker build not detecting updates
I run a build on a node application and then use the artifacts to build a docker image. The COPY command that moves my source in place isn't detecting changes to the source files after a build; its ...
37
votes
10
answers
156k
views
How to solve "Could not find any Python installation to use" with docker node alpine Image when adding bcrypt to package.json?
Before I added bcrypt to my package.json, everything was working fine. Now, I get the error message below.
This is an excerpt of my package.json:
"dependencies": {
"bcrypt": "3.0.6",
"...
37
votes
3
answers
16k
views
Docker containers and Node.js clusters
I have an api server running Node.js that was using it's cluster module and testing looked to be pretty good. Now our IT department wants to move to using Docker containers which I am happy about but ...
36
votes
12
answers
139k
views
Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:71:19)
after building my react docker image I tried to run docker run image_name
and after that the log throw this error
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:...
35
votes
5
answers
20k
views
Deprecation warning when installing nodejs on docker container using nodesource install script
I used to install nodejs on Debian based container using the following in the Dockerfile:
RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq curl git nano
RUN curl -...
32
votes
2
answers
107k
views
Docker: Error response from daemon: OCI runtime create failed: container_linux.go:296:
I am trying to run a simple node application with express but I get this error:
Here's my working directory:
I ran the following command to mount my current source code directory to /var/www inside ...
32
votes
4
answers
19k
views
Running Ruby, Node, Python and Docker on the new Apple Silicon architecture? [closed]
How do you get a Ruby, Python and Node.js development environments running on Apple Silicon architecture. What about virtualization software e.g. Docker?
31
votes
6
answers
53k
views
MongoDB on with Docker "failed to connect to server [localhost:27017] on first connect "
I am using mongoDB with and NodeJS backend. The Problem is I am getting the following error
node:16) UnhandledPromiseRejectionWarning: MongoNetworkError: failed
to connect to server [localhost:...
31
votes
3
answers
22k
views
Docker: Are node alpine images at the end smaller than full node images?
I'm running a cluster of nodeJS applications - which should be very small as they are run as microservices. Only a few of them need extra things like bcrypt or imagemagick - which makes some trouble ...
30
votes
8
answers
20k
views
Extract package.json version using shell script
I'm trying to extract the value of the version field in package.json from the build.sh file. Is there a way to do this? Looks like i can use the below to do the extraction, but what if node is not ...
30
votes
13
answers
63k
views
@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again
I am using prisma, postgres, docker, kubernets.
npx prisma migrate dev working.
and npx prisma generate produce below output:
✔ Generated Prisma Client (2.23.0) to ./node_modules/@prisma/client in ...
29
votes
6
answers
25k
views
tar EPERM: operation not permitted, futime
I have a node:alpine Docker image. When I run the image as a root user, I have no problems, but when I use another user and I try to do npm install I receive a lot of errors from package extraction:
...
29
votes
12
answers
31k
views
How to stop running node in docker
I have just installed dockers and installed node.
I am able to run a basic express site. My issue now is I can't stop it. Control-C is not doing anything.
Temporarily what I did to exit was:
Close ...
29
votes
2
answers
23k
views
Docker - Override or remove ENTRYPOINT from a base image
I'm using Docker (version 1.12.2, build bb80604) to setup a simple image/container with Gatling (Load Testing tool) + NodeJS. So, I pulled this Docker/Gatling base image and created my own Dockerfile ...
29
votes
6
answers
57k
views
Docker - "Error: EACCES: permission denied, mkdir '/project/node_modules/.cache/@babel'"
Running yarn docker-build works fine but when yarn docker-up or yarn docker-dev an error pops up when RUN yarn is called. Nginx starts up fine but yarn fails into mkdir in the Projects directory.
...
29
votes
3
answers
21k
views
Can Intellij be used with a Visual-Studio-Code style docker devcontainer?
I've been using devcontainers in Node development in VSC and enjoy the idea that I can commit a shared configuration to ensure everyone on the team has the same runtime/buildtime. I've been looking ...
29
votes
1
answer
8k
views
Performance and reliability when using multiple Docker containers VS standard Node cluster
Performance and reliability when using multiple Docker containers VS standard Node cluster
Hi, I have a question regarding the performance, reliability and growth potential of two setups that I've ...
28
votes
5
answers
27k
views
M1 Related! - Prisma: Can't reach database server at `database`:`5432`
Since I have moved to the new Apple Silicon architecture my docker setup with nextjs and postgres is not working anymore. The database inside the docker cannot be found by the nextjs server where I am ...
28
votes
4
answers
29k
views
docker-compose volume on node_modules but is empty
I'm pretty new with Docker and i wanted to map the node_modules folder on my computer (for debugging purpose).
This is my docker-compose.yml
web:
build: .
ports:
- "3000:3000"
links:
- ...
28
votes
8
answers
41k
views
Create Docker container with both Java and Node.js
I am not sure why I expected this to work:
# Dockerfile
FROM node:6
FROM java:8
but it doesn't really work - looks like the first command is ignored, and second command works.
Is there a ...
28
votes
8
answers
25k
views
Node and docker - how to handle babel or typescript build?
I have a node application that I want to host in a Docker container, which should be straight forward, as seen in this article:
https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
In my project, ...
28
votes
3
answers
48k
views
How to pass environment variables from docker-compose into the NodeJS project?
I have a NodeJS application, which I want to docker-size.
The application consists of two parts:
server part, running an API which is taking data from a DB. This is running on the port 3000;
client ...
28
votes
5
answers
33k
views
Should Dockerfile execute "npm install" and "npm run build" or should it only copy those files over?
I'm a little new to Docker and trying to wrap my head around some of the concepts.
In a lot of tutorials and articles (actually, almost all of them), this is a typical Dockerfile for a create-react-...