{"id":29120188,"url":"https://github.com/anirudhuuu/docker-kubernetes","last_synced_at":"2026-04-15T13:33:40.756Z","repository":{"id":295022209,"uuid":"988824828","full_name":"anirudhuuu/docker-kubernetes","owner":"anirudhuuu","description":"docker \u0026 kubernetes: build, deploy \u0026 scale on aws","archived":false,"fork":false,"pushed_at":"2025-06-11T06:28:04.000Z","size":11803,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-28T19:34:55.741Z","etag":null,"topics":["devops","docker","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/anirudhuuu.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-05-23T06:12:14.000Z","updated_at":"2025-10-30T15:38:29.000Z","dependencies_parsed_at":"2025-05-23T07:54:27.662Z","dependency_job_id":"da781cce-dc85-4877-94d5-f695f667e62e","html_url":"https://github.com/anirudhuuu/docker-kubernetes","commit_stats":null,"previous_names":["jwala-anirudh/docker-kubernetes","anirudhuuu/docker-kubernetes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/anirudhuuu/docker-kubernetes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirudhuuu%2Fdocker-kubernetes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirudhuuu%2Fdocker-kubernetes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirudhuuu%2Fdocker-kubernetes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirudhuuu%2Fdocker-kubernetes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anirudhuuu","download_url":"https://codeload.github.com/anirudhuuu/docker-kubernetes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirudhuuu%2Fdocker-kubernetes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31842940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T13:28:40.153Z","status":"ssl_error","status_checked_at":"2026-04-15T13:28:29.396Z","response_time":63,"last_error":"SSL_read: 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":["devops","docker","kubernetes"],"created_at":"2025-06-29T14:38:00.686Z","updated_at":"2026-04-15T13:33:40.742Z","avatar_url":"https://github.com/anirudhuuu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker and Kubernetes\n\n## Containers\n\n![containers](./01-containers/docker%20containers.png)\n\n### How?\n\n![under the hood](./01-containers/under%20the%20hood%20docker.png)\n\n### Why?\n\n![why](./01-containers/why%20to%20use.png)\n\n### Working\n\n![working](./01-containers/docker%20working.png)\n\n### Commands\n\n![commands](./01-containers/docker%20commands.png)\n\n## Essentials\n\n### Images\n\n![images](./02-essentials/docker%20images.png)\n\n### Containers\n\n![containers](./02-essentials/docker%20containers.png)\n\n### Dockerfile\n\nAn overall view of working with containers is as follows:\n![overall view](./02-essentials/overall%20view.png)\n\nPlan of action will be as follows:\n\n1. Create a fresh react app\n2. Create a docker image\n3. Spin up a container with that image\n4. Perform updates in the application\n5. Make a fresh image of the updated application\n6. Sipn up a new container with the updated image\n\n### Command to build an image\n\n```bash\ndocker build -t react-docker .\n```\n\n![docker file logs](./02-essentials/docker%20file%20logs.png)\n\nwithout caching it would look like following:\n\n![docker file logs no cache](./02-essentials/docker%20file%20logs%20-%20no%20cache.png)\n\n### Command to run the image\n\nThe format for porting is `\u003ccomputer port\u003e:\u003ccontainer port\u003e`\n\n```bash\ndocker run -p 5173:5173 react-docker\n```\n\nSince the vite application server needs the host to be defined we have set in the `vite.config.js` file the following:\n\n```javascript\nexport default defineConfig({\n  server: {\n    host: \"0.0.0.0\",\n    port: 5173,\n  },\n});\n```\n\n### Command to rebuild the image\n\nafter making changes to the application we need to rebuild the image for the changes to take effect.\n\nFor versioning we can use\n\n```bash\ndocker build -t react-docker:2 .\n```\n\nTo rebuild the exact same image we can use\n\n```bash\ndocker build -t react-docker .\n```\n\nOptimised logs for the docker rebuild of image\n\n![docker file logs rebuild](./02-essentials/docker%20file%20logs%20optimised%20for%20rebuild.png)\n\nOutput would be like following for the react app\n![react output](./02-essentials/react%20output.png)\n\n## Common Commands\n\nRuns a container based on the image\n\n```bash\ndocker run \u003cimage-name\u003e\n```\n\nRuns a container based on the image in detached mode\n\n```bash\ndocker run -d \u003cimage-name\u003e\n```\n\nProvide a name to the container\n\n```bash\ndocker run --name \u003ccontainer-name\u003e \u003cimage-name\u003e\n```\n\nRun on a specific port\n\n```bash\ndocker run -p \u003chost-port\u003e:\u003ccontainer-port\u003e \u003cimage-name\u003e\n```\n\nLoad present working directory into the container\n\n```bash\ndocker run -v $(pwd):/app \u003cimage-name\u003e\n```\n\nExecute in an interactive mode, this will allow you to run commands inside the container using `/bin/bash` or `sh` shell\n\n```bash\ndocker run -it \u003cimage-name\u003e /bin/bash\n```\n\n```bash\ndocker run -it \u003cimage-name\u003e sh\n```\n\n## More Commands\n\nList all the running containers\n\n```bash\ndocker ps\n```\n\nList all the containers (including stopped ones)\n\n```bash\ndocker ps -a\n```\n\nList logs of a container\n\n```bash\ndocker logs \u003ccontainer-name\u003e\n```\n\nGet attached to a running container, just to get inside the container\n\n```bash\ndocker attach \u003ccontainer-name\u003e\n```\n\nStop a running container\n\n```bash\ndocker stop \u003ccontainer-name\u003e\n```\n\nContainer is stuck or processing something, force stop it\n\n```bash\ndocker kill \u003ccontainer-name\u003e\n```\n\nStop all the active running containers\n\n```bash\ndocker stop $(docker ps -q)\n```\n\nRestart a container\n\n```bash\ndocker restart \u003ccontainer-name\u003e\n```\n\nStart a stopped container\n\n```bash\ndocker start \u003ccontainer-name\u003e\n```\n\nRemove a container\n\n```bash\ndocker rm \u003ccontainer-name\u003e\n```\n\nContainer is busy, force remove it\n\n```bash\ndocker rm -f \u003ccontainer-name\u003e\n```\n\nDelete all the stopped containers\n\n```bash\ndocker \u003ccontainer-name\u003e prune\n```\n\nCopy a file from the container to the host\n\n```bash\ndocker cp \u003ccontainer-name\u003e:/path/to/file /path/on/host\n```\n\n## Dockerise an Express App\n\nBuild an image for an express app\n\n```bash\ndocker build -t express-app .\n```\n\n![build output](./02-essentials/docker-express-app/build%20process.png)\n\nRun a container with the image with environment variables passed in-line\n\n```bash\ndocker run -p 4000:3000 -e PORT=3000 --rm express-app\n```\n\n![output of express app](./02-essentials/docker-express-app/output.png)\n\nRun a container with the image with environment variables passed in a file\n\n```bash\ndocker run -p 4000:3000 --env-file .env --rm express-app\n```\n\n## Multi-Stage Docker build\n\n```bash\ndocker build -t express-mutli-stage .\n```\n\n![multi-stage build output](./02-essentials/docker-express-multi-stage/build%20output.png)\n\n## Networking\n\nBasic networking in docker allows containers to communicate with each other and the outside world.\n\n```bash\ndocker run --rm -it busybox sh\n\nhostname\n\nping google.com\n\nifconfig\n\nexit\n```\n\n![basic](./03-networking/basic%20google%20ping.png)\n\n`eth0` is the default network interface in docker containers. eth stands for Ethernet network interface. `veth` stands for virtual Ethernet network interface. `docker0` is the master interface for the docker bridge network that talks to the host machine.\n\n![container networking](./03-networking/containers%20networking.png)\n\nTo list all the networks in docker, you can use the following command:\n\n```bash\ndocker network ls\n```\n\n| NETWORK ID   | NAME   | DRIVER | SCOPE |\n| ------------ | ------ | ------ | ----- |\n| 287fceb8c8d1 | bridge | bridge | local |\n| 30a4b9d415b7 | host   | host   | local |\n| 66118539c033 | none   | null   | local |\n\nRead more regarding network drivers in docker [here](https://docs.docker.com/engine/network/drivers/).\n\n| NETWORK TYPE     | DESCRIPTION                                                                      |\n| ---------------- | -------------------------------------------------------------------------------- |\n| bridge (default) | containers on the same host can communicate, external access needs port mapping. |\n| host             | The container shares the host's networking namespace (no isolation)              |\n| none             | No network connectivity (completely isolated)                                    |\n| overlay          | Enales multi-host networking for Swarm services                                  |\n| macvlan          | Assigns a real MAC address to the container (acts like a physical device)        |\n\n## Networking Commands\n\nList all the networks\n\n```bash\ndocker network ls\n```\n\nInspect a network\n\n```bash\ndocker network inspect \u003cnetwork-name\u003e\n```\n\nCreate a new network\n\n```bash\ndocker network create \u003cnetwork-name\u003e\n```\n\nRun a container in a specific network\n\n```bash\ndocker run --network \u003cnetwork-name\u003e \u003ccontainer-name\u003e\n```\n\nAttach a running container to a network\n\n```bash\ndocker network connect \u003cnetwork-name\u003e \u003ccontainer-name\u003e\n```\n\nDisconnect a container from a network\n\n```bash\ndocker network disconnect \u003cnetwork-name\u003e \u003ccontainer-name\u003e\n```\n\nRemove a network\n\n```bash\ndocker network rm \u003cnetwork-name\u003e\n```\n\n## Docker Networking Hands-on\n\nList all the networks\n\n```bash\ndocker network ls\n```\n\nCreate a new network\n\n```bash\ndocker network create my-bridge\n```\n\n![network created](./03-networking/create%20network.png)\n\nCreate a new container in the network\n\n```bash\ndocker run --network my-bridge --name container1 -d nginx\n```\n\n![container created](./03-networking/container%20with%20network.png)\n\nCreate another container in the same network on alpine image\n\n```bash\ndocker run --network my-bridge --name container2 -d alpine sleep 3600\n```\n\n![alpine container created](./03-networking/two%20containers%20in%20same%20network.png)\n\nPing the nginx container from the alpine container\n\n```bash\ndocker exec -it container2 ping container1\n```\n\n![ping output](./03-networking/ping%20container.png)\n\n## Docker Compose\n\nDocker Compose is a tool for defining and running multi-container Docker applications. It allows you to define services, networks, and volumes in a single YAML file.\n\n```yml\n# Full-stack application with React frontend, Node.js backend, and PostgreSQL database\n# Uses custom network for inter-service communication\n\n# React frontend service - serves UI on port 3000\n# Waits for backend to be ready before starting\n\n# Node.js backend API service - runs on port 5001\n# Connects to PostgreSQL database using environment variables\n# Waits for database to be ready before starting\n\n# PostgreSQL database service - uses Alpine Linux for smaller image size\n# Automatically restarts if container stops\n# Data persisted using named volume 'pgdata'\n\n# Named volume for PostgreSQL data persistence\n\n# Custom bridge network for service communication\n# Allows services to communicate using service names as hostnames\nversion: \"3.8\"\n\nservices:\n  frontend:\n    build: ./frontend\n\n    ports:\n      - \"3000:80\"\n\n    depends_on:\n      - backend\n\n    networks:\n      - my-custom-network\n\n  backend:\n    build: ./backend\n\n    ports:\n      - \"5001:5000\"\n\n    environment:\n      DB_HOST: database\n      DB_USER: postgres\n      DB_PASS: password\n      DB_NAME: postgres\n\n    depends_on:\n      - database\n\n    networks:\n      - my-custom-network\n\n  database:\n    image: postgres:16-alpine\n\n    restart: always\n\n    environment:\n      POSTGRES_USER: postgres\n      POSTGRES_PASSWORD: password\n      POSTGRES_DB: postgres\n\n    volumes:\n      - pgdata:/var/lib/postgresql/data\n\n    networks:\n      - my-custom-network\n\nvolumes:\n  pgdata:\n\nnetworks:\n  my-custom-network:\n    driver: bridge\n```\n\n![compose output](./04-compose/docker%20compose%20-%201.png)\n\n![compose output 2](./04-compose/docker%20compose%20-%202.png)\n\n![compose output 3](./04-compose/docker%20compose%20-%203.png)\n\n![compose output 4](./04-compose/docker%20compose%20-%204.png)\n\n![compose output 5](./04-compose/docker%20compose%20-%205.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanirudhuuu%2Fdocker-kubernetes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanirudhuuu%2Fdocker-kubernetes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanirudhuuu%2Fdocker-kubernetes/lists"}