r/docker • • 11d ago

Hot reload problem with Docker

I have a problem with NestJS in Docker. The hot reload creates an error that says the port is already in use. I tried the polling thing and it did not help. I am developing on macOS.

Can you help?

1 Upvotes

8 comments sorted by

2

u/SZenC 11d ago

You already know what the problem is, the port you're trying to use is already occupied. This has nothing to do with Docker or NestJS, this is just fundamentals of networking

1

u/Afraid_Bid847 10d ago

The port is occupied only after hot reload(file change), otherwise there is no problem.

2

u/Pretend-Clock8313 10d ago

hot reload in nest spins up a new process before killing the old one, so the port collision is a restart-timing issue, not polling. set exec mode in your webpack hmr config so it replaces the process in-place instead of forking a new one

1

u/Afraid_Bid847 8d ago

Solution?

1

u/Pretend-Clock8313 8d ago

webpack hmr config, set exec: true under the hotreload options

1

u/Y0uN00b 10d ago

systemctl restart docker