{"id":18837296,"url":"https://github.com/clarenceb/nginx-demo","last_synced_at":"2026-04-30T12:33:46.774Z","repository":{"id":142072089,"uuid":"178338376","full_name":"clarenceb/nginx-demo","owner":"clarenceb","description":"Basic container demo using nginx","archived":false,"fork":false,"pushed_at":"2019-12-09T00:10:01.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-29T19:39:26.480Z","etag":null,"topics":["demo","docker","nginx"],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/clarenceb.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}},"created_at":"2019-03-29T05:29:12.000Z","updated_at":"2019-12-09T00:10:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"99d81711-8a0a-4a8f-881d-2499c35b9f17","html_url":"https://github.com/clarenceb/nginx-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/clarenceb/nginx-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarenceb%2Fnginx-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarenceb%2Fnginx-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarenceb%2Fnginx-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarenceb%2Fnginx-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clarenceb","download_url":"https://codeload.github.com/clarenceb/nginx-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarenceb%2Fnginx-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32465009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"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":["demo","docker","nginx"],"created_at":"2024-11-08T02:34:41.209Z","updated_at":"2026-04-30T12:33:46.744Z","avatar_url":"https://github.com/clarenceb.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NGINX demo\n\n## Part 1 - Standalone Container\n\n### Build a Docker image\n\n```sh\ndocker build -t nginx-demo .\n```\n\n### Build a smaller Docker image (based on alpine line)\n\n```sh\ndocker build -t nginx-demo:alpine -f Dockerfile.alpine .\n```\n\n### Check sizes of images built\n\n```sh\ndocker images | grep nginx-demo\n```\n\n### Inspect the metadata and layers of the image(s)\n\n```sh\ndocker inspect nginx-demo | jq\ndocker history nginx-demo:latest\n```\n\n### Start a container based on the image\ndocker run -d -p 8080:80 --name nginx-demo nginx-demo\ndocker ps\n\n### Test the nginx web server is accessible via the host machine\n\n```sh\ncurl http://localhost:8080\n```\n\n### Open an interactive bash terminal inside the container\n\n```sh\ndocker exec -ti nginx-demo bash\n```\n\n### Install some tools to check processes running inside container\n\n```sh\napt-get install -y procps net-tools\nps -ef\ntop\nls -al\nexit\n```\n\n### Mounting a volume\n\n```sh\ndocker run -d -p 8080:80 -v $(pwd)/web:/var/www/html:ro --name nginx-demo nginx-demo\n```\n\n### Remove the container\n\n```sh\ndocker rm -f nginx-demo\n```\n\n## Part 2 - Multiple Containers\n\nCreate a user-defined network:\n\n```sh\ndocker network create nginx-demo\n```\n\nRun a JSON API container:\n\n```sh\ndocker run -d -p 8081:80 --network nginx-demo -v $(pwd)/api:/var/www/html:ro -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro --name nginx-api nginx-demo\n```\n\n```sh\ncurl -H \"Accept: application/json\" localhost:8081/countries.json | jq\n```\n\nRun the web client that fetches the JSON API data:\n\n```sh\ndocker run -d -p 8080:80 --network nginx-demo -v $(pwd)/web2:/var/www/html:ro --name nginx-demo2 nginx-demo\n```\n\nFrom within the `nginx-web2` container, the api could be access using the `nginx-api` DNS name:\n\n```sh\ndocker exec -ti nginx-demo2 bash\napt install curl -y\ncurl -H \"Accept: application/json\" http://nginx-api:8081/countries.json\nexit\n```\n\n### Remove the containers\n\n```sh\ndocker rm -f nginx-api\ndocker rm -f nginx-demo2\n```\n\n### Use Docker Compose\n\n```sh\ndocker-compose up\n```\n\nAccess the websites:\n- http://localhost:8080\n- http://localhost:8082\n\nPress CTRL+C to stop containers and exit Docker Compose.\n\n## Kubernetes\n\n### Prerequisites\n\n* Kubernetes cluster\n* `kubectl` installed and configured to access your Kubernetes cluster\n\nIf you need a cluster you can use [Minikube](https://minikube.sigs.k8s.io/) or create one on [Azure with AKS](https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough).\n\n### Publish Docker image (if using DockerHub)\n\nTo Docker Hub (use your Docker login and repository name):\n\n```sh\ndocker login\ndocker tag nginx-demo clarenceb/nginx-demo\ndocker push clarenceb/nginx-demo\n```\n\n### Publish Docker image (if using ACR with AKS)\n\nTo Azure Container Registry:\n\n```sh\naz group create --name myacr --location australiaeast\naz acr create --resource-group myacr --name \u003cmyacr-unique-name\u003e --sku Basic\naz acr login --name \u003cmyacr-unique-name\u003e\ndocker tag nginx-demo \u003cmyacr-unique-name\u003e.azurecr.io/nginx-demo\ndocker push \u003cmyacr-unique-name\u003e.azurecr.io/nginx-demo\n```\n\nGrant access to your AKS cluster to pull images form ACR:\n\n```sh\nACR_ID=$(az acr show -n \u003cmyacr-unique-name\u003e --query id -o tsv)\naz aks update -n \u003caks-cluster-name\u003e -g \u003caks-resource-group\u003e --attach-acr $ACR_ID\n```\n\n### Pods\n\n```sh\nkubectl run nginx-demo --image=\u003cmyacr-unique-name\u003e.azurecr.io/nginx-demo --generator=run-pod/v1 --port=8080\nkubectl get pod\nkubectl describe pod/nginx-demo\n```\n\nPort forward to access the pod from localhost:\n\n```sh\nkubectl port-forward pod/nginx-demo 8080:80\n```\n\nCleanup:\n\n```sh\nkubectl delete pod/nginx-demo\n```\n\nWith a Kubernetes Manifest:\n\n```sh\nkubectl apply -f kubernetes/pod.yaml\nkubectl get pod\nkubectl describe pod/nginx-demo\nkubectl port-forward pod/nginx-demo 8080:80\nkubectl delete pod/nginx-demo\n```\n\n### Relica Sets\n\n\"A ReplicaSet’s purpose is to maintain a stable set of replica Pods running at any given time. As such, it is often used to guarantee the availability of a specified number of identical Pods.\" - [Source](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/).\n\n\nWith a Kubernetes Manifest:\n\n```sh\nkubectl apply -f kubernetes/replica-set.yaml\nkubectl get rs\nkubectl get pod\nkubectl describe rs/nginx-demo-rs\nkubectl port-forward rs/nginx-demo-rs 8080:80\n\n# Try killing a pod, the dpeloyment brings it back.\nkubectl get pods\nkubectl delete pod/nginx-deployment-c5c5db647-5ms8q\nkubectl get pod\nkubectl describe rs/nginx-demo-rs\n\n# Cleanup\nkubectl delete rs/nginx-demo-rs\n```\n\n### Deployments\n\n\"A Deployment provides declarative updates for Pods and ReplicaSets.\n\nYou describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. You can define Deployments to create new ReplicaSets, or to remove existing Deployments and adopt all their resources with new Deployments.\" - [Source](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)\n\nWith a Kubernetes Manifest:\n\n```sh\nkubectl apply -f kubernetes/deployment.yaml\nkubectl get deploy\nkubectl get rs\nkubectl get pod\nkubectl describe deploy/nginx-deployment\nkubectl port-forward deployment/nginx-deployment 8080:80\n# Try killing a pod, the dpeloyment brings it back.\nkubectl get pods\nkubectl delete pod/nginx-deployment-c5c5db647-5ms8q\nkubectl get pod\nkubectl describe deploy/nginx-deployment\n\n# Cleanup\nkubectl delete deployment/nginx-deployment\n```\n\nYou can perform a rolling update with Deployments:\n\n```sh\nkubectl set image deployment/nginx-deployment nginx-demo=clarenceb/nginx-demo:v2\n```\n\nSee: https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-intro/\n\n### Services\n\n```sh\nkubectl apply -f kubernetes/service.yaml\n```\n\nWait for Load Balancer IP.\n\n```sh\nkubectl get svc\n# EXTERNAL-IP\n# xx.xx.xx.xx\n```\n\nAccess the dmeo: http://xx.xx.xx.xx\n\nIf using Minikube, change `type: LoadBalancer` to `type: NodePort` and use one of the Node IPs to access the sort.\n\nCleanup:\n\n```sh\nkubectl delete deployment/nginx-deployment\nkubectl delete svc/nginx-demo-svc\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclarenceb%2Fnginx-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclarenceb%2Fnginx-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclarenceb%2Fnginx-demo/lists"}