{"id":23822497,"url":"https://github.com/shashanksrivatsarao/docker-compose-practice","last_synced_at":"2026-06-26T09:31:56.443Z","repository":{"id":266089597,"uuid":"897352396","full_name":"ShashankSrivatsaRao/Docker-Compose-Practice","owner":"ShashankSrivatsaRao","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-08T13:24:59.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-12T09:04:55.453Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ShashankSrivatsaRao.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-02T13:38:51.000Z","updated_at":"2024-12-08T13:25:02.000Z","dependencies_parsed_at":"2024-12-02T14:44:18.626Z","dependency_job_id":"d9d60814-a433-4146-a47c-1f39ce9eacd7","html_url":"https://github.com/ShashankSrivatsaRao/Docker-Compose-Practice","commit_stats":null,"previous_names":["shashanksrivatsarao/docker-compose-practice"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ShashankSrivatsaRao/Docker-Compose-Practice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShashankSrivatsaRao%2FDocker-Compose-Practice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShashankSrivatsaRao%2FDocker-Compose-Practice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShashankSrivatsaRao%2FDocker-Compose-Practice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShashankSrivatsaRao%2FDocker-Compose-Practice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShashankSrivatsaRao","download_url":"https://codeload.github.com/ShashankSrivatsaRao/Docker-Compose-Practice/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShashankSrivatsaRao%2FDocker-Compose-Practice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34811915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-26T02:00:06.560Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-01-02T09:19:57.376Z","updated_at":"2026-06-26T09:31:56.425Z","avatar_url":"https://github.com/ShashankSrivatsaRao.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  TASK  :TO CREATE 2 CONTAINERS AND ESTABLISH CONNECTION\n## This outlines the steps I took to complete the tasks and demonstrate the basic functionality of Docker Compose. \n\n**Description** : I was tasked with spinning up two containers, Flask and SQL, and connecting the Flask container to the database container.\n\n### Step 1: \n**I created a folder for my project and initialized it with git init.**\n\n\n ```bash\n mkdir flask-app\n cd flask-app\n git init\n ```\n\n### Step 2\n\n **I created an app.py file with a basic Flask program to display \"Hello, World,\" and then wrote a Dockerfile to build an image and run a container with all required dependencies and port mappings.**\n   \n ```bash\ntouch app.py  # Created a hello world message using Flask\ntouch Dockerfile # Added a Dockerfile to containerize the app\ntouch requirements.txt # Listed all dependencies (Flask)\n\n# Built and ran the Docker image\ndocker build -t flaskapp:latest .\ndocker run -p 3000:3000 flaskapp:latest\n\n# Accessed the app at 127.0.0.1:3000 to verify the hello world message.\n```\n\n ### Step 3 \n **1.I updated the app.py file to establish database connections.**\n**2.Created a docker-compose.yml file to launch multiple containers.**\n\n***NOTE: I connected to the database container by using the service name as the DB_HOST in the environment variables.***\n\n ```bash\ntouch docker-compose.yml\n# Added all database content to the database container using PostgreSQL.\n# Built the previously written Dockerfile into a container running the Flask app.\n```\n\n ***Challenges: In the build section of the flask-app container in the YAML file, I added a dot to indicate that the build should use the current Dockerfile.***\n\n***The database container's name is crucial for communication.***\n\n\n ### Step 4 \n\n **Executed all containers simultaneously with Docker Compose.**\n\n ```bash\n docker compose build\n docker compose up\n ```\n\n### Challenges: ### \n **Configuring the correct Python file name in the Dockerfile RUN command.**\n **2\u003eBuild: This command is utilized to create an image from a Dockerfile located in the current directory as specified in the YAML file.**\n **3\u003eVerified the connection by accessing the container and executing the command.**\n \n   ```\n   docker exec \u003cid\u003e -it bash\n   psql -U testuser -d testdb \n   ```  \n **3\u003e I was unable to access the database within the psql container. So took the following steps.**\n \n ```bash\n docker exec \u003ccontainer_id\u003e -it bash\n #root@\u003ccontainer_id\u003epsql -U rootuser -d testdb\n #testdb: /l  this will list the databses and the tables in the server\n ```\n \n\n ## Conclusion:\n **1. Acquired knowledge on how to connect containers to one another using the Docker Compose YAML file.  \n2. Understood the significance of port mapping and the process of writing a Dockerfile.  \n3. Learned the principles of Docker Compose.**\n\n # THANK YOU SHASHANK S\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshashanksrivatsarao%2Fdocker-compose-practice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshashanksrivatsarao%2Fdocker-compose-practice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshashanksrivatsarao%2Fdocker-compose-practice/lists"}