aws / aws/aws-lambda-base-images
[NodeJS] Cannot use node inspector, port in use
- Dominant language
- No language data
- Stars
- 777
- Forks
- 118
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to run the Node 22 image on my local and want to start the process with inspect flag, for doing so I passed the env var `NODE_OPTIONS` but on container startup I get an error that the port specified is in use.
**Docker compose:**
```yaml
my-service:
build: ../backend/my-service
depends_on:
- db
restart: always
container_name: my-service
ports:
- "6012:5001"
environment:
NODE_OPTIONS: "--inspect=0.0.0.0:5001"
```
**Dockerfile:**
```yaml
FROM public.ecr.aws/lambda/nodejs:22
COPY . /var/task/
WORKDIR /var/task/
CMD [ "my-service.lambda.handler" ]
```
**Container logs**
```
Debugger listening on ws://0.0.0.0:5001/cb34b78e-0c31-4521-babf-1f3f28589426
For help, see: [https://nodejs.org/en/docs/inspector](https://nodejs.org/en/docs/inspector)
Debugger attached.
> my-service@1.0.0 start
> nodemon ./my-service/bin/www
Starting inspector on 0.0.0.0:5001 failed: address already in use
```
**Exec inside container**
```sh
sh-5.2# lsof -i :5001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
npm\x20st 1 root 26u IPv4 4162282 0t0 TCP *:commplex-link (LISTEN)
npm\x20st 1 root 32u IPv4 4163286 0t0 TCP 21a7612f5aad:commplex-link->192.168.63.1:59388 (ESTABLISHED)
```
The problem persists even when I change ports (I have tried a lot of them)
Contributor guide
Assessment
This issue has not been assessed yet.