3 months ago
PROBLEM DESCRIPTION
Docker build on Railway is stuck indefinitely at:
[internal] load metadata for docker.io/library/python:3.9-slim
[internal] load metadata for docker.io/library/node:20-alpineAfter ~30 minutes, the build times out with:
Build Failed: build daemon returned an error < failed to run Build function: Canceled: context canceled >ROOT CAUSE
Railway's Docker build environment has slow/blocked access to Docker Hub.
The build cannot fetch metadata for base images from Docker Hub within the timeout window.
This is NOT a code issue - it's an infrastructure/network issue with Railway's build servers.
WHAT WE ALREADY TRIED
Attempt 1: Blamed SHAP Library 
What we did: Removed shap==0.43.0 from
backend-requirements.txt
Why it failed: The build was stuck BEFORE pip runs, so SHAP wasn't the issue.
Result: Didn't help - build still timed out at Docker metadata fetch.
Attempt 2: Added PyPI Mirror Optimization 
What we did: Added Aliyun PyPI mirror to Dockerfile:
dockerfileRUN mkdir -p ~/.pip && echo "[global]\nindex-url = https://mirrors.aliyun.com/pypi/simple/" > ~/.pip/pip.confWhy it failed: The build never gets to pip install - it's stuck at base image pull.
Result: Didn't help - build still times out at Docker metadata fetch.
Attempt 3: Added BuildKit Optimization 
What we did: Added BuildKit syntax to Dockerfile:
dockerfile# syntax=docker/dockerfile:1.4Why it failed: BuildKit helps with caching, but doesn't solve the base image pull timeout.
Result: Didn't help - build still times out at Docker metadata fetch.
Attempt 4: Verified .dockerignore 
What we did: Checked
.dockerignore file (already optimized)
Result: File is good, but doesn't solve the base image pull issue.
2 Replies
3 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
3 months ago
I see you disabled "Enable metal build environment" which resolves this. We're working on a fix for this at the moment, thanks for reporting! Going to consider this resolved as you're now unblocked 🫡
Status changed to Awaiting User Response Railway • 3 months ago
Status changed to Solved ray-chen • 3 months ago