Code and more documentation can be found in this repo
Expected behavior:
Receive a response when running the app with and without docker.
What I got:
A response when running the app without docker but not inside docker.
What I think the problem could be:
The app seems to be working inside docker but the port just not passing through correctly.
What I already tried:
yarn start:dev
inside the docker container instead of yarn start:prod
. This did nothing, but then again the ports that where used where the same.- target: 3000
published: 3000
protocol: tcp
mode: host
As this issue (this comment) explains
If no host is specified, NestJS will bind to localhost
This caused me to be unable to connect with the service while it was running in docker. So by setting the host to 0.0.0.0
I was able to connect over TCP.
Full example:
const app = await NestFactory.createMicroservice(AppModule, {
transport: Transport.TCP,
options: {
host: '0.0.0.0',
port: 3000
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With