Skip to content
Running container does not match the image built from our Dockerfile
riider2050
OP

8 hours ago

Hello Railway team,

We have a production service where the running container provably does not reflect the image that our Dockerfile build produces, and we have exhausted every mechanism on our side. We are asking you to investigate what artefact the deployment is actually being served from. (We are on the Hobby plan, so we are posting publicly as instructed; we can share the project and service IDs privately with Railway staff on request.)

The symptom. Our app measures its own Python toolchain in the running process (importlib.metadata in the interpreter that serves traffic). It consistently reports pip 24.0 / setuptools 79.0.1 — the stock toolchain of the python:3.11-slim base image. Our Dockerfile's final stage installs requirements.txt, which pins pip==26.3 and setuptools==84.2.1, and the build ends with a hard assertion: if the installed pip is not 26.3 or setuptools is not 84.2.1, the build fails. Builds succeed — so every image actually built from our source carries the pinned pair. The running process never does.

Configuration (verified in the dashboard on 2026-12-05). Builder = Dockerfile, path backend/Dockerfile, set via /railway.toml in the repo. GitHub auto-deploy is disabled; deploys happen only via railway up --ci from our GitHub Actions. No custom build command, no custom start command, no root directory override, no watch paths.

Four controlled deployments, same result:

  1. A CI deploy (2026-12-05 ~00:08 MT) — deploy completed, image digest reported in the deploy log; running process stamps pip 24.0 / setuptools 79.0.1.
  2. A pure redeploy of that same deployment from the dashboard (2026-12-05 ~07:39 MT) — same stamp.
  3. "Skipped Builds" disabled in the service settings, then the Deploy job re-run end-to-end (fresh railway up, 2026-12-05 ~08:15 MT) — same stamp.
  4. A brand-new merge commit with a fresh CI build and deploy (2026-12-05 ~09:57 MT) — deploy completed, image pushed to Railway's registry per the job log; running process still stamps pip 24.0 / setuptools 79.0.1.

The measurement is not stale: our in-app watchdog re-measures the live process on demand, and a manual run after deployment 2 re-stamped the same stock values.

What we are asking. Why does the running container not reflect the image built from our Dockerfile? Is the service being run from a different artefact than the one the build produces (for example a cached or substituted image), and how do we get deployments to serve the image that was actually built?

Thank you,

Rahul Chawdhary (account owner)

$20 Bounty

6 Replies

Status changed to Awaiting Railway Response Railway • about 8 hours ago


Railway
BOT

8 hours ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway • about 8 hours ago


8 hours ago

That pair is stock python:3.11-slim. The official image installs setuptools==79.0.1 and leaves pip at 24.0. If your pins had hit the interpreter serving traffic, both numbers would have moved.

EDIT: Railway is not swapping in a cached or different image. The container is the image that build produced. That image still has the stock Python from python:3.11-slim, pip 24.0 and setuptools 79.0.1. Those are the versions the official base image installs. Your pins never landed in the Python that actually starts.

Railway runs the last stage only. The version check can pass in an earlier stage, or inside a venv, and the last stage still boots /usr/local/bin/python from a fresh python:3.11-slim. Skipped builds are not involved. railway up builds every time, and a redeploy rebuilds too.

Put the pip install and the version check after the last FROM, and start that same Python (if you used a venv, put it on PATH in that stage). Then the running process and the image you just built are the same thing.

Quick way to see it: last line of the last stage, write the versions into /etc/toolchain-stamp. If the live process can read that file and it says 24.0, the last stage never installed your pins. If the file says 26.3 but the app still reports 24.0, you are starting the wrong Python, or RAILWAY_VOLUME_MOUNT_PATH is covering /usr/local or the venv.


kevinchen1104

7 hours ago

Rahul, I'd add one value to the next manual watchdog run: the deployment ID of the process that served the request. Compare it with the ID of the deployment whose final-stage assertion passed (09:57 MT in your post), and check whether the dashboard marks that deployment Active. The build log's image digest and the deployment ID identify different things. railway up --ci exits when the build finishes, before you know whether the new container is serving requests. See CLI behavior and deployment states.

If the IDs differ, check which service and environment the domain routes to, then check the newer deployment's status and healthcheck. If the IDs match, use the watchdog's own interpreter to check where it found each package:

import os, sys
from importlib.metadata import distribution

print("deployment", os.getenv("RAILWAY_DEPLOYMENT_ID"), "python", sys.executable)
for name in ("pip", "setuptools"):
    dist = distribution(name)
    print(name, dist.version, str(dist.locate_file("")))

Compare the interpreter and package paths with the output from the same snippet in your final Docker stage. If the paths match but versions differ, check whether a volume covers either package path. If that still doesn't explain it, post the comparison here with identifiers redacted. Offer the deployment ID, image digest and request time privately if Railway staff ask. The variable reference lists both the deployment ID and the volume mount path.

AI-assisted. I tested the snippet with two package locations under one interpreter. I can't see your deployment.


riider2050
OP

5 hours ago

Update — NO_CACHE discriminator run (5 Dec 2026): we set NO_CACHE=1 on the production service and redeployed. The build log confirms caching was disabled and every layer rebuilt from scratch, including a fresh pip install of all 298 requirements (the pre-upgrade step and the requirements install both executed; the image was exported and pushed normally). Immediately afterwards we ran our in-app dependency watchdog manually against the new running process: it still detects pip 24.0 / setuptools 79.0.1 (the python:3.11-slim stock pair) via /usr/local/bin/python — not the pinned pip 26.3 / setuptools 84.2.1 that the build installed. This is the sixth controlled deployment with the same result, and it eliminates the build layer cache as a cause: a 100% cache-free build still yields a running container whose toolchain does not match the image that was built and pushed. The mismatch therefore appears to sit between the pushed image and the running container. Any guidance on how we can compare the digest of the image actually running against the digest that was pushed would be very welcome.


5 hours ago

You can compare those two digests in the dashboard. Open the deployment that is Active and read the digest on it. Put that next to the digest from this NO_CACHE build. Also print RAILWAY_DEPLOYMENT_ID from the watchdog and confirm it is this deployment. The process cannot see its own image digest, so there is nothing else to query from inside.

If those two digests differ, the container serving traffic is not the one this build pushed. Stay on that deployment until you see why it never went Active.

If they match, the running container is the image that was pushed, and that image really does contain /usr/local/bin/python with pip 24.0 and setuptools 79.0.1. The pip install in the log ran in a stage that was not exported. Docker prints every stage, then exports only the last FROM. Scroll that build log for a FROM python:3.11-slim that comes after the pip install. That later stage is what got pushed. A fresh base stage is exactly the stock pair you are measuring.

A volume only fits if the digests match and RAILWAY_VOLUME_MOUNT_PATH covers /usr/local. Otherwise this is the last stage, not a swap between push and run.


riider2050
OP

2 hours ago

Follow-up (5 Dec 2026): we attempted the digest comparison suggested here. The build log for the active deployment (the NO_CACHE rebuild) records the produced image digest sha256:3a01f1c638c6d153a0134afc1ad6b1d942df15b93df80e7a5f91d470b326c05c, pushed to the Railway registry under a tag equal to the deployment ID. However, the dashboard exposes no image digest for the deployment itself in any view (details, raw config JSON, status, deploy or network tabs), so from the customer side there is no way to verify which artefact the deployment is actually running from. Could Railway staff please check on their side which image digest the active deployment 2f09f064 is being served from, and whether it equals the digest above?


riider2050
OP

2 hours ago

Follow-up 2 (5 Dec 2026): we have now completed the digest comparison through Railway's public API. For the active deployment 2f09f064, the deployment record's own meta.imageDigest is sha256:3a01f1c638c6d153a0134afc1ad6b1d942df15b93df80e7a5f91d470b326c05c — identical to the digest in the build log. The same record shows commitHash 1e7e353, which matches the running app's revision stamp, and volumeMounts is empty, so no volume overlays the toolchain paths. In other words, Railway's own records say this deployment runs the image whose build asserted pip 26.3 / setuptools 84.2.1, yet the live process in that deployment still measures pip 24.0 / setuptools 79.0.1. The build record, the deployment record and the commit all agree; only the running container disagrees. Could Railway staff please explain what the running container is actually started from when the deployment record carries this digest?


Welcome!

Sign in to your Railway account to join the conversation.

Loading...