404 No Such Service in lightsail and flask app

0

I am having trouble getting a hello world Flask app up and running on lightsail. I am following this tutorial.

I am at the end of Step 4 where I deploy the container. My service-name is flask-service2, and after running

aws lightsail create-container-service-deployment --service-name flask-service2 --containers file://containers.json --public-endpoint file://public-endpoint.json

then aws lightsail get-container-services --service-name flask-service2, the console displays

"containerServiceName": "flask-service2",
...
"state": "READY",
...
"url": "https://flask-service2.********.us-east-1.cs.amazonlightsail.com/",

When I navigate to this url, though, I receive a browser 404 No Such Service. In the lightsail console, I go to Containers > flask-service2 > Deployments then there is a date with my deployment, and it says Status Failed. I click the three dots, Show details, Open log and the only thing that shows is

[8/Feb/2024:10:17:08] [deployment:3] Creating your deployment
[8/Feb/2024:10:18:11] [deployment:3] Started 1 new node
[8/Feb/2024:10:19:13] [deployment:3] Started 1 new node
[8/Feb/2024:10:20:07] [deployment:3] Started 1 new node
[8/Feb/2024:10:20:26] [deployment:3] Canceled

I have Example: [DEBUG], and it still shows this after Refresh. I am ultimately trying to view the detailed logs of the container deployment, so I can understand why the container deployment has failed.

I have read this page, but I am not sure what to stdout to view all errors, and I have read this page, but the instructions seem to match what I am already doing.

app.py

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
   return "Hello, world"

if __name__ == "__main__":
   app.run(host='0.0.0.0', port=5000)

containers.json

{
    "flask": {
        "image": "flask-service2.flask-container2.3",
        "ports": {
            "5000": "HTTP"
        }
    }
}

Dockerfile

# Set base image (host OS)
FROM python:3.12-alpine

# By default, listen on port 5000
EXPOSE 5000/tcp

# Set the working directory in the container
WORKDIR /app

# Copy the dependencies file to the working directory
COPY requirements.txt .

# Install any dependencies
RUN pip install -r requirements.txt

# Copy the content of the local src directory to the working directory
COPY app.py .

# Specify the command to run on container start
CMD [ "python", "./app.py" ]

public-endpoints.json

{
    "containerName": "flask", 
    "containerPort": 5000
}

requirements.txt

flask==3.0.0 

I also have .env and .gitignore but am not using them.

Jeff F
asked 4 months ago206 views
1 Answer
0
Accepted Answer

Good Day Jeff,

Thanks for putting up your query here. I tried replicating the tutorial via using same steps as you did with a little difference which I noted in your containers.json file i.e., "image": "flask-service2.flask-container2.3", >> which should be "image": ":flask-service2.flask-container2.3", >> When you compare both, you will see ":" and "." inserted by me. Plus, I tried using Amazon ECR Private Repository via LightSail Service via AWS Console, that also worked as expected and Public-Endpoint was throwing "Hello World!".

Secondly, coming to viewing the logs, the method is the same as specified at: https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-viewing-container-service-container-logs and use different filters accordingly i.e., "crit, error, warn, info, debug".

Meanwhile, in case of any further queries/clarifications > Please feel free to raise a Support Case via AWS Support Center with our AWS Support Engineering Team.

Have an AWSome Day Ahead & Stay Safe!

profile pictureAWS
SUPPORT ENGINEER
answered 4 months ago
  • This has solved the problem. I inserted the colon, so "image": ": flask-service2.flask-container2.3", and now it works! Thank you Ramneek.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions