Skip to content
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

Bind 0.0.0.0 in docker env #57

Closed
delvedor opened this issue Apr 9, 2018 · 7 comments
Closed

Bind 0.0.0.0 in docker env #57

delvedor opened this issue Apr 9, 2018 · 7 comments

Comments

@delvedor
Copy link
Member

delvedor commented Apr 9, 2018

If you run a Fastify server in Docker by default it will run on the address 127.0.0.1 which is not reachable from outside.
We can add an is docker check and if it is true, use 0.0.0.0 instead of 127.0.0.1.

What do you think?

@ninjatux
Copy link
Contributor

ninjatux commented Apr 9, 2018

it's a sensible thing to do if by default we want a working service limiting options and arguments when running in docker

@mcollina
Copy link
Member

mcollina commented Apr 9, 2018

I would do this by default if bundled within docker.

@delvedor
Copy link
Member Author

Closed in #58

@pyrossh
Copy link

pyrossh commented Apr 19, 2018

Damn'it I'm too late. Just ran into it when using docker. Would have been easier if I had seen this earlier.

@PierBover
Copy link

I think something is broken here.

fastify.listen(process.env.PORT || 3000, '0.0.0.0', function (err, address) {
	if (err) {
		fastify.log.error(err)
		process.exit(1)
	}
	fastify.log.info(`server listening on ${address}`)
});

When running on regular Node I get Server listening on http://0.0.0.0:3000 as expected.

But when running in Docker I get Server listening at http://127.0.0.1:8080 so the server cannot be reached.

Wasn't this PR by @mcollina supposed to add 0.0.0.0 by default when running in Docker?

#58

It seems now it's actually overwriting the address and using 127.0.0.1 instead.

Or maybe I'm missing something...

@mcollina
Copy link
Member

I do not think you are running your server using fastify-cli. Are you using this module at all?

The snippet above is not from this module.

@PierBover
Copy link

Ooops sorry @mcollina I totally missed this wasn't the main Fastify repo.

hochoy added a commit to hochoy/node-chatgpt-starter that referenced this issue Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants