2 months ago
[internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1745885067 333 ms
[internal] load .dockerignore
[internal] load .dockerignore 0 ms
[internal] load .dockerignore
[internal] load .dockerignore 10 ms
[5/5] COPY . /app
[4/5] RUN pip install -r backend/requirements.txt
[3/5] COPY . /app/.
[internal] load build context
[2/5] WORKDIR /app/
[internal] load build context 0 ms
[internal] load build context
[1/5] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1745885067@sha256:d45c89d80e13d7ad0fd555b5130f22a866d9dd10e861f589932303ef2314c7de 9 ms
[2/5] WORKDIR /app/ 0 ms – CACHED
[internal] load build context 2 sec
[3/5] COPY . /app/.
[3/5] COPY . /app/. 1 sec
[4/5] RUN pip install -r backend/requirements.txt
/bin/bash: line 1: pip: command not found
✕ [4/5] RUN pip install -r backend/requirements.txt
process "/bin/bash -ol pipefail -c pip install -r backend/requirements.txt" did not complete successfully: exit code: 127
Dockerfile:15
-------------------
13 | # build phase
14 | COPY . /app/.
15 | >>> RUN pip install -r backend/requirements.txt
16 |
17 |
-------------------
ERROR: failed to build: failed to solve: process "/bin/bash -ol pipefail -c pip install -r backend/requirements.txt" did not complete successfully: exit code: 127
Error: Docker build failed
2 Replies
2 months ago
Hey there! We've found the following might help you get unblocked faster:
🧵 Build Failure: npm: not found in Nixpacks Python/Node.js Project
🧵 Forcing fresh Docker builds on Railway (cache not invalidating)
If you find the answer from one of these, please let us know by solving the thread!
2 months ago
Cause
Your Dockerfile is FROM ghcr.io/railwayapp/nixpacks:ubuntu…
, which is a minimal base used by Nixpacks. It doesn’t include Python or pip, so pip install …
fails with pip: command not found
.
Fix (pick one)
If you do A or B, the pip
error goes away and the backend will deploy cleanly.
Option A: Let Railway/Nixpacks handle Python (no Dockerfile)
1. Put your Python app (and
requirements.txt
) in the service root (or set your service to build from thebackend/
subdir).2. Add a start command (e.g. via
nixpacks.toml
):
toml
# nixpacks.toml
[start]
cmd = "gunicorn backend.main:app --bind [::]:${PORT-8000}"
Nixpacks auto-detects Python & sets up a venv with pip; it will run the start command on ${PORT}
.
Option B: Keep Dockerfile, use a Python base image
Replace your FROM
with an official Python image and install deps:
dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY backend/ .
# your app must bind to $PORT on Railway
CMD ["gunicorn","backend.main:app","--bind","[::]:${PORT-8000}"]
This is the clean, fast path for Python Docker builds.
Option C: If you insist on the Nixpacks base image
Explicitly install Python + pip first, then run your install:
dockerfile
FROM ghcr.io/railwayapp/nixpacks:ubuntu-<tag>
WORKDIR /app
COPY . /app
RUN apt-get update && apt-get install -y python3 python3-pip && ln -sf /usr/bin/pip3 /usr/bin/pip
RUN pip install --no-cache-dir -r backend/requirements.txt
CMD ["gunicorn","backend.main:app","--bind","[::]:${PORT-8000}"]
(This works, but is slower/heavier than Option B.)
Notes
If you’re deploying from a monorepo (e.g., code in
/backend
), make sure the service builds/starts from that directory or set proper paths/commands; otherwise Nixpacks can’t pick the right plan.Your server must listen on
${PORT}
for Railway to route traffic. If Nixpacks can’t detect a start command, set one explicitly.