Docker Build Success But Container Not Running
jonathancarpenter
PROOP

a month ago

Docker build succeeds but Railway serves static files instead of my Nginx container.

Issue:

- Build: white_check_mark emoji "Using Detected Dockerfile" (107.79s)

- Runtime: x emoji server: railway-edge + npm serve warnings

- Expected: Nginx with security headers

Config:

- Project: TL;CR Portal (frontend service)

- railway.toml: builder = "DOCKER"

- Dockerfile: Node.js → Nginx, CMD ["nginx", "-g", "daemon off;"]

Tried:

- Changed RAILPACK → DOCKER

- Removed railway.json conflicts

- CLI redeploy

- Local Docker works fine

Question: Why doesn't Railway run my built container? Need Nginx for OWASP compliance.

Domain: http://www.tlcr.app

$10 Bounty

3 Replies

Can you share your Dockerfile?


Status changed to Awaiting User Response Railway about 1 month ago


Railway
BOT

a month ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open Railway about 1 month ago


angelo-railway

Can you share your Dockerfile?

jonathancarpenter
PROOP

a month ago

# BACKUP PLAN: Nginx with Security Headers

# Use this if Node.js approach continues failing

FROM node:18-alpine AS builder

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build

FROM nginx:alpine

# Copy built React app

COPY --from=builder /app/build /usr/share/nginx/html

# Create nginx config with security headers

RUN cat > /etc/nginx/conf.d/default.conf << 'EOF'

server {

listen 3000;

location / {

root /usr/share/nginx/html;

index index.html;

try_files $uri $uri/ /index.html;

# OWASP Security Headers

add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://js.stripe.comhttps://*.js.stripe.comhttps://connect-js.stripe.comhttps://checkout.stripe.comhttps://maps.googleapis.comhttps://www.google.comhttps://www.gstatic.com 'sha256-ZswfTY7H35rbv8WC7NXBoiC7WNu86vSzCDChNWwZZDM='; style-src 'self' https://fonts.googleapis.com 'unsafe-hashes' 'sha256-0hAheEzaMe6uXIKV4EehS9pu1am1lj/KnnzrOYqckXk=' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' 'sha256-KwBwKPFQYZQuI8e2rC0gallUsT+s3HG8P1NomLjTznI=' 'sha256-0X6e6+JJNMIiI0QvONa3MQd23nMpxGHgF4DDDnQUgyQ=' 'sha256-tgop8y+GPeD6eSCE26wWvzlvhD4J1EcX9kn0nm+gvx0=' 'sha256-ZZT7BttQkSLnKeGYVLWT6p9QPxHVCh/WYk0ig1lS+wE=' 'sha256-iGl4GTIcqe3iRKZBrgKakHH0fW4JQLFzqcmfcMDcKxY=' 'sha256-3YR+oThqihXxsG6OVL44sDSLdarA9HNwZmEUmM5e+XI=' 'sha256-bbI7A2Rh882yl0Q+pCvSW8tq3PrLaqGu9LELvmZ3CRU=' 'sha256-iBf9ZPsoOTQ5Rpj6CK+67FayusU+QAOjUdDMbg5GR88=' 'sha256-rh7Up7sWkYe+rU4phcn0TbecqcRxQF4WQcCRZCCmAZI=' 'sha256-gdvfgOXNGNJez/3VEPaX7oDPmmsuSUeIT+IkOp8lpzQ=' 'sha256-frxZ/9PfmeWtdT3zzQClevQ7upQZbKaw31MfnaGzd3c=' 'sha256-mFWK/VA8QspAVFChOuRO0DOA8qNdhZySQxJ98Oe7YZk=' 'sha256-XcLIpR/A9IfXZBS+1WnHF8DFVJZPVqWqc8iPG/YJh3A=' 'sha256-lGQTax0D7mID0Zfd7Q1ukRqBv67WxlIrrI+D2q+MAtM=' 'sha256-q8XnBv2g/pPys6UOf9zPswqwzC3AA+uFHKIvopdQAxc=' 'sha256-JIoRo200EqApFKymx93P+J5I2M8ge1gN4I5NDkfc84Q=' 'sha256-xqGRoXxNErpG2B6cFDGxomhqvFSBrkEDUlodVnjgId8=' 'sha256-XtpGG9Aa3QThjWn0zzq1hXAAyAIVPexOKeK0SpGK9JY='; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob: https://*.stripe.com; connect-src 'self' https://api.stripe.comhttps://maps.googleapis.com; frame-src 'self' https://js.stripe.comhttps://*.js.stripe.comhttps://connect-js.stripe.comhttps://checkout.stripe.com; form-action 'self'; base-uri 'self'; object-src 'none'; upgrade-insecure-requests; frame-ancestors 'none'";

add_header X-Frame-Options "DENY";

add_header X-Content-Type-Options "nosniff";

add_header X-XSS-Protection "1; mode=block";

add_header Referrer-Policy "strict-origin-when-cross-origin";

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";

add_header Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=(self), usb=(), bluetooth=(), magnetometer=(), gyroscope=(), accelerometer=()";

add_header Cross-Origin-Embedder-Policy "require-corp";

add_header Cross-Origin-Opener-Policy "same-origin";

add_header Cross-Origin-Resource-Policy "same-origin";

}

}

EOF

EXPOSE 3000


shobhit-nagpal
HOBBY

a month ago

hey, i recently deployed an angular application with nginx through Docker. the Dockerfile looks correct where you're copying the final build of the app to the nginx html dir. i suspect it's the 3000 which might be causing an issue

i faced issues in 2 things:

  • the target port that i was using. i had kept it as 4200 but that did no good. in my Dockerfile, i kept the nginx port as 80 on the target port under custom domain and also exposed 80 in docker

  • i ssh'ed into my instance under the project to check what was actually present in the nginx/html dir. turns out, i had put the wrong dir to copy the final build from into my nginx/html

for ssh'ing into the instance, you can use the railway cli and after linking, use the railway ssh command


Loading...