-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
nodemon with babel-node in docker address already in use #1477
Comments
Can you provide a dockerfile? I don't use docker so I don't know how to run these things |
It's simple @remy, I setup this for development only, I mounted the current directory with the container so it's mirrored and for that reason I don't need to copy the
|
I noticed that it only works without
to:
and use this as script:
It works, it doesn't however when using |
I'm having the same issue when running with docker-compose. However, adding |
@richardkall I haven't tested the |
@zefexdeveloper Ah…you say "simple" like I'm supposed to know how docker works. What do I need to run those files? I've assumed docker for Mac, but how do I start it and test it? |
@remy Oh, sorry, I thought you knew, my bad, that is why I said it's simple, because indeed the file is pretty simple. |
@richardkall I just tried using
|
Weird, for me it's working with the
./api/Dockerfile: FROM node:10.13.0-alpine as base
WORKDIR /app
COPY package.json .
COPY yarn.lock .
RUN yarn --frozen-lockfile
COPY . . docker-compose.yml: version: '3.7'
services:
api:
build:
context: ./api
target: base
command: yarn dev
container_name: api
ports:
- 4000:4000
tty: true
volumes:
- /app/node_modules
- ./api:/app
web:
... ./api/package.json: {
"engines": {
"node": "^10.13.0",
"yarn": "^1.10.1"
},
"scripts": {
"dev": "nodemon --signal SIGINT -e ts -x 'babel-node --extensions .ts' src"
},
"devDependencies": {
"@babel/node": "^7.0.0",
"nodemon": "^1.18.7",
...
}
} |
@richardkall It's still not working for me, I noticed that you are not using the legacy watch, for me if I don't use
btw: my settings are not that different from yours. |
I'm facing the same issue. This has started after I upgraded from Also I'm controlling the shutdown of my server with the approach described at https://github.com/remy/nodemon#controlling-shutdown-of-your-script but I don't seem to ever receive One more thing, if I start and immediately change a file I can clearly see the logs of 2 servers starting, the first one with success and the second one failing due to I've tried to debug but I can't seem to find much, not familiar with the nodemon codebase. @remy is there a build process if I change the source or I can just push the code to my fork and npm install from there? |
To add some more details on this issue, I've been using nodemon to hot reload my API inside docker for the past 2 months. It was worked extremely well with no issues. After I upgraded I began to experience OPs issue.
Modifying my command to use --signal SIGINT as suggested above didn't solve the issue. However, I tested my API outside of docker with and without --signal SIGINT and it reloads correctly in both scenarios. I can't debug much further right now but hopefully this bit of info can help. |
I face the same issue and I believe somehow it is a In the following ...
"start:dev": "nodemon --watch './src' --exec 'npm start'"
... by: ...
"start:dev": "nodemon --watch './src'"
... it works perfectly under docker. Here is the test case: src/index.js const express = require('express');
const app = express();
app.listen(17600, () => {
console.log('Server MediaStreamTrackAudioSourceNode, Olé !');
}); package.json {
"name": "nodemon-test",
"version": "1.0.0",
"description": "",
"main": "./src/index.js",
"scripts": {
"start": "node .",
"start:dev": "nodemon --watch './src' --exec 'npm start'"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.16.4"
},
"devDependencies": {
"nodemon": "^1.18.7"
}
} Dockerfile FROM node:10-alpine
WORKDIR /app
COPY ./src /app/src
COPY ./package.json /app/package.json
COPY ./package-lock.json /app/package-lock.json
RUN npm install
CMD [ "npm", "start" ] docker-compose.yml version: '3.7'
services:
node:
build: .
command: npm run start:dev
ports:
- 17600:17600
volumes:
- ./src:/app/src
- ./package.json:/app/package.json Note: I need |
@OlivierCuyp see Nodemon inside a docker container requires the use of the legacy watch flag -L However, even after I use legacy watch like OP my nodemon script does not correctly restart. I am also using I'm using nodemon the following way:
|
Let's wait for @remy to see what he has to say about that, the next steps. |
@20k-ultra To my understanding under OSX docker is not using virtualbox with vboxsf since a long time so the |
Same error using linux, docker, yarn and ts-node. Dockerfile:
package.json:
Versions:
Error in terminal:
But if I exec into the running container I can't find the blocking process:
|
@tibotiber I tried to reinstall the version
Note: I didn't checked all versions between |
@remy if you need help for testing let me know if I can do something. |
@OlivierCuyp @spalberg @20k-ultra @tibotiber Try sharing your Dockerfile for development as well so we can test or help @remy or anyone else interesting in fixing this. |
This issue is affecting my workflow so I'll try my best to be as helpful as possible! Here's a repo I've made to make it very easy to reproduce the issue. Should be easy for new docker users to use as well. |
@OlivierCuyp I'm surprised @zefexdeveloper here is my setup:
docker-compose (parts)
yarn script
Note: I've moved to |
To be honest with you guys I'm really considering not using Docker for development mostly because Docker volumes doesn't make a lot of sense for it anyway. It doesn't matter if your Dockerfile copy your package.json, install the dependencies, when you mount the volume the host files will override the container files anyway, and it might be even worse if your host is Windows and the container is using Linux, if a module needs compilation 100% sure you will have problems. Perhaps keep the development locally and use the containers for things like Postgres, NGINX, Redis and so on, at the end you might create a Dockerfile for your API and/or client in prod as you won't have the volume issues. Nevermind, in resume you can use Docker for development, you just have to be sure you are mounting the right directory as volume, don't |
@zefexdeveloper I posted a full test case up in the issue: here. For the dev Docker chat, we should find an other place to discuss it. I'll be glad to share my experience with it. @tibotiber I check the |
Hi guys. PS: I don't have --exec parameter in my startup script. But I faced with the same issue. |
I have a feeling (though I'm on a mobile phone so it's not straight forward to confirm), that nodemon@1.12.x was pre-chokidar which meant it used the Any more digging you're able to do is definitely a help! |
@remy don't think chokidar is the issue here. Since file changes are catched by nodemon. |
@GryaznovGI could you provide your startup script ? |
Basically: dupe of #1484 and it's in progress now - feel free to follow along there if you want to see how I fixed it. |
Live fix in nodemon@1.18.8 (core change in pstree.remy…again). |
@remy Thank you very much for the effort. I will be testing the changes today. |
Just add |
Anyone else from the future visiting this, I had to make sure my volume was mounted in docker-compose.yml to get nodemon to find the files. |
I encountered this issue trying to get
The solution for me was to install
|
Thank you! This solved the issue for me as well. |
I configured a simple app in express to run in a docker container but whenever I make a change nodemon gives me an error saying that the port is already in use.
That is my start script:
nodemon -L --exec babel-node -- src/index
"nodemon": "^1.18.7"
and my
index.js
:It's like it's not closing the process and it's trying to execute again
The text was updated successfully, but these errors were encountered: