{"id":28857984,"url":"https://github.com/km-saifullah/docker-with-flask-app","last_synced_at":"2026-05-08T13:02:12.434Z","repository":{"id":297654183,"uuid":"997444758","full_name":"km-saifullah/docker-with-flask-app","owner":"km-saifullah","description":"In this repository is all about the dockerize a simple python app","archived":false,"fork":false,"pushed_at":"2025-06-06T16:01:51.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-20T02:04:07.472Z","etag":null,"topics":["docker","flask","flask-application","python","ubuntu-server"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/km-saifullah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-06T14:36:20.000Z","updated_at":"2025-06-06T16:20:56.000Z","dependencies_parsed_at":"2025-06-06T17:29:42.704Z","dependency_job_id":null,"html_url":"https://github.com/km-saifullah/docker-with-flask-app","commit_stats":null,"previous_names":["km-saifullah/docker-with-flask-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/km-saifullah/docker-with-flask-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/km-saifullah%2Fdocker-with-flask-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/km-saifullah%2Fdocker-with-flask-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/km-saifullah%2Fdocker-with-flask-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/km-saifullah%2Fdocker-with-flask-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/km-saifullah","download_url":"https://codeload.github.com/km-saifullah/docker-with-flask-app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/km-saifullah%2Fdocker-with-flask-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32781561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","flask","flask-application","python","ubuntu-server"],"created_at":"2025-06-20T02:04:07.911Z","updated_at":"2026-05-08T13:02:12.425Z","avatar_url":"https://github.com/km-saifullah.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dockerizing a Python Flask Application\n\nIn this project, I will demonstrate how to create a simple Python application using the Flask framework and then containerize it using Docker. You can follow the steps outlined below to achieve the same result.\n\n![Project Architecture](https://res.cloudinary.com/dmysnb0x5/image/upload/v1749223055/Hardware_rmnroe.png)\n\n## Requirements\n\nThis project was developed and tested on **Ubuntu Server**, so the setup instructions below are tailored for Ubuntu users.\n\n- **Docker Installed**: To build and run the Dockerized Flask application, you must have Docker installed on your machine.\n\nIf you're using **Ubuntu**, follow the official installation guide from Docker:  \n [Install Docker on Ubuntu – Official Documentation](https://docs.docker.com/engine/install/ubuntu/)\n\n## Step-1: Create the necessary directories and files required to structure and run the Flask application\n\nCreate the project’s root directory and initialize all the necessary files required for building and running the Flask application.\n\n```bash\nmkdir flask_app\ncd flask_app\ntouch app.py requirements.txt Dockerfile\n```\n\n## Step-2: Implement the Python application logic inside the **app.py** file\n\nIn this step you will write the application code inside the **app.py** file, which will serve as the main entry point for your Flask application.\n\n```python\nfrom flask import Flask, request, jsonify\n\napp = Flask(__name__)\n\n# In-memory task list\ntasks = []\n\n@app.route('/')\ndef home():\n    return \"Welcome to the Flask Todo App\"\n\n@app.route('/tasks', methods=['GET'])\ndef get_tasks():\n    return jsonify(tasks)\n\n@app.route('/tasks', methods=['POST'])\ndef add_task():\n    data = request.get_json()\n    task = {'id': len(tasks) + 1, 'title': data.get('title')}\n    tasks.append(task)\n    return jsonify(task), 201\n\n@app.route('/tasks/\u003cint:task_id\u003e', methods=['DELETE'])\ndef delete_task(task_id):\n    global tasks\n    tasks = [t for t in tasks if t['id'] != task_id]\n    return '', 204\n\nif __name__ == '__main__':\n    app.run(debug=True, host='0.0.0.0')\n\n```\n\n## Step-3: Add the necessary dependencies to the **requirements.txt** file\n\nAt this stage you should list all required Python packages in the `requirements.txt` file to ensure the application runs correctly.\n\n```bash\nflask\n```\n\n## Step-4: Write the **Dockerfile** instructions to build the image for this application\n\nIn this step you will create a `Dockerfile` that contains all the necessary instructions to build a Docker image for your Flask application. This includes setting up the base image, installing dependencies, copying application files and defining the command to run the app.\n\n```bash\nFROM python:3.10-slim\n\nWORKDIR /app\n\nCOPY requirements.txt .\n\nRUN pip install -r requirements.txt\n\nCOPY app.py .\n\nCMD [\"python\",\"app.py\"]\n```\n\n## Step-5: Build the docker image\n\nIn this step you will build the docker image using the `Dockerfile` you created in the previous step. This process packages your Flask application and its dependencies into a portable image that can run consistently across different environments.\n\n```bash\ndocker build -t flask-app .\n```\n\n## Step-6: Run the Docker Container\n\nIn this step you will run a Docker container from the image you built. This will start your Flask application in an isolated environment making it accessible via the specified port on your local machine or server.\n\n```bash\ndocker run -d -p 5000:5000 --name=flask-app-container --restart=always flask-app\n```\n\n**Note**: `--restart=always` Ensures the container automatically restarts if it crashes, or when the Docker daemon restarts. Useful for keeping the app running continuously.\n\n## Step-7: Test the application in the browser and CLI\n\n1. Test in the browser: Open your browser and navigate to\n\n```bash\nhttp://localhost:5000\nhttp://your_machine_ip_address:5000\n```\n\n2. Test using CLI: You can also test the application from the command line using `curl`\n\n```bash\ncurl http://localhost:5000\n```\n\n## Reach out to me\n\nIf you have any questions, feedback or collaboration ideas feel free to connect with me:\n\n- [LinkedIn](https://www.linkedin.com/in/kmsaifullah)\n- [GitHub](https://github.com/km-saifullah)\n\nI'm always open to connecting with fellow developers and tech enthusiasts. Let's build something amazing together!\n\n## Conclusion\n\nBy following the steps above, you have successfully built and containerized a simple Flask application using Docker. This approach ensures your application runs consistently across different environments and simplifies deployment and scalability.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkm-saifullah%2Fdocker-with-flask-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkm-saifullah%2Fdocker-with-flask-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkm-saifullah%2Fdocker-with-flask-app/lists"}