Dockerfile with node alpine can't access database internal network
When I up a Dockerfile with a normal image from node, this is work, but when I up a Dockerfile with an image alpine they can't access the same database in internal network, someone can help me ?
Solution:Jump to solution
you are right, but they aren't running anything that uses the private network during build, their issues is because they are using an alpine image.
https://docs.railway.app/guides/private-networking#workaround-for-alpine-based-images...
24 Replies
Project ID:
8e7a534e-bfc1-40ca-a40a-9695fda79d5a
8e7a534e-bfc1-40ca-a40a-9695fda79d5a
I may be wrong, but I believe private networking is not available during build, so you wouldn’t be able to reference a db in a dockerfile
@Brody lmk if that’s right
not sure what you’re doing in said dockerfile that requires a database. Can you elaborate on your use case?
In my case I'm just using the dockerfile to configure the node version and then execute commands in the terminal through a .sh file, as I'm using Prisma I need to perform the generate and deploy commands, sorry for not explaining it before.
I can put here Dockerfile for you see ?
for sure, go for it
please wrap it in backticks so it shows as code
migrate-and-start.sh:
Try removing your start command from your Dockerfile and add it as a start command in your Railway service or in a railway.json
https://docs.railway.app/guides/config-as-code
Right now you're starting your service in your dockerfile, which would start it in your build steph which is why it's failing.
hummm that makes sense , but when i change the image ( FROM) for a version normal node like node:21 it's work and i don't recive this erros ( i don't know why )
I wouldn’t know why either
i try use a config as code, but i don't know i do this corret skskksks
it's right ?
Solution
you are right, but they aren't running anything that uses the private network during build, their issues is because they are using an alpine image.
https://docs.railway.app/guides/private-networking#workaround-for-alpine-based-images
go back to this dockerfile (no need for a railway.json)
and a tip, you don't need to install bash, just use sh instead
ho it's work !!!!!
you added the alpine specific variable right?
Thanks so much @Adam and @Brody, you guys are awesome
you say that rigth ENABLE_ALPINE_PRIVATE_NETWORKING=true ?
I'm just now noticing this, please please do not run a development server on railway
you say about ?
yes
Even if it is a development environment ?
development servers cost more to run and come with increased instabilities and much lower performance
oww ok, i don't have no idea about that, i will change that
sounds good