skip to Main Content

git repo : https://github.com/samAd0san/two-tier-flask-app.git

I have used the Dockerfile to build an image, then proceeded by running a flask app container.

docker run -d -p 5000:5000 --network=twotier 
           -e MYSQL_HOST=mysql 
           -e MYSQL_USER=admin 
           -e MYSQL_PASSWORD=admin 
           -e MYSQL_DB=myDb 
           --name=flaskapp flaskapp:latest

The problem occurs when I launch this command:

docker ps -a
2860157851d9   
flaskapp:latest   
"python app.py"

      5 minutes ago   Exited (1) 5 minutes ago

flaskapp

The container should run on executing the command so that I can deploy the flask app on the container and it is connected with mysql container.

Ultimately I’m not able to access the application.

2

Answers


  1. Check the Container logs by Command: docker logs <container id>.

    Another thing I suggest is you should copy all data to /app as you defined WORKDIR /app.

    Login or Signup to reply.
  2. The fact that your Flask app container exited with status code 1 indicates that there was an issue during startup or execution. To diagnose the problem, you should examine the container’s logs to identify the specific error.

    docker ps -a
    docker logs <container_id>

    The container logs should provide more information about what went wrong during the container’s startup.

    After reviewing the container logs and addressing any issues you find, you should be able to run the Flask app container successfully, and your Flask app should be accessible.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search