I am having issue with container was died

10 months ago

i am deploying my fastapi code on the railway app through github. i have use dockerfile and railway.toml file

in deploy log i am getting like the application is running on 0.0.0.0:8000 but i am not able to access this via given link.

I try to check the log and i got like this Starting Container

Jul 09 19:43:28respectful-purpose

INFO: Started server process [2]

Jul 09 19:43:28

respectful-purpose

INFO: Waiting for application startup.

Jul 09 19:43:28

respectful-purpose

INFO: Application startup complete.

Jul 09 19:43:28

respectful-purpose

INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)

Jul 09 19:43:36

respectful-purpose

container event container died

Here is my docker file for your reference

# Use an official Python runtime as a parent image

FROM python:3.12-slim

# Set the working directory in the container

WORKDIR /app

# Copy the current directory contents into the container at /app

COPY . /app

# Install necessary packages

RUN apt-get update && apt-get install -y \

wget \

gnupg \

unzip \

curl \

&& rm -rf /var/lib/apt/lists/*

# Download and install Chrome

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \

&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \

&& apt-get update && apt-get install -y google-chrome-stable

# Download and install ChromeDriver

RUN wget -q "https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip" -O /tmp/chromedriver.zip \

&& unzip /tmp/chromedriver.zip -d /usr/local/bin/ \

&& rm /tmp/chromedriver.zip

# Set display port to avoid crash

ENV DISPLAY=:99

# Install any needed packages specified in requirements.txt

RUN pip install --no-cache-dir -r requirements.txt

# Expose necessary ports

EXPOSE 8080

EXPOSE 5000

EXPOSE 8000

# Run app.py when the container launches

CMD ["sh", "-c", "uvicorn app:app --host=0.0.0.0 --port=${PORT:-8000}"]and here is railway.toml file

[services]

[[services.app]]

image = "python:3.12-slim"

cmd = "uvicorn app:app --host 0.0.0.0 --port ${PORT:-8000}"

envs = { PORT = "8000" }

[services.app.deploy]

build_command = "pip install -r requirements.txt"Please solve this issue I am so bored to solve this

0 Replies

I am having issue with container was died - Railway Help Station