{"id":40627403,"url":"https://github.com/amirhnajafiz-presentations/docker","last_synced_at":"2026-01-21T07:27:42.413Z","repository":{"id":76922922,"uuid":"426723164","full_name":"amirhnajafiz-presentations/docker","owner":"amirhnajafiz-presentations","description":"What is Docker?","archived":false,"fork":false,"pushed_at":"2025-06-08T04:33:30.000Z","size":406,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-31T18:30:10.975Z","etag":null,"topics":["docker","docker-container","docker-network","docker-volume","nodejs","redis","shell"],"latest_commit_sha":null,"homepage":"","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/amirhnajafiz-presentations.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":"2021-11-10T17:56:55.000Z","updated_at":"2025-06-08T04:33:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"d51d15a4-6dc5-4abf-bfa0-c60e9741213d","html_url":"https://github.com/amirhnajafiz-presentations/docker","commit_stats":null,"previous_names":["amirhnajafiz-presentations/docker","amirhnajafiz-teaching/docker"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/amirhnajafiz-presentations/docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirhnajafiz-presentations%2Fdocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirhnajafiz-presentations%2Fdocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirhnajafiz-presentations%2Fdocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirhnajafiz-presentations%2Fdocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amirhnajafiz-presentations","download_url":"https://codeload.github.com/amirhnajafiz-presentations/docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirhnajafiz-presentations%2Fdocker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28629915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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","docker-container","docker-network","docker-volume","nodejs","redis","shell"],"created_at":"2026-01-21T07:27:41.705Z","updated_at":"2026-01-21T07:27:42.400Z","avatar_url":"https://github.com/amirhnajafiz-presentations.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker\n\n![](https://img.shields.io/github/languages/top/amirhossein-teaching/docker?style=flat-square)\n![](https://img.shields.io/github/v/release/amirhossein-teaching/docker?style=flat-square)\n\nWelcome to **Docker** practicual example. In this repository we are going to build containers with **Docker**. Next we are going to make communications\nbetween our containers using **Docker Network**, and\nwe are going to bind our local file system to container\nfile system using **Docker Volumes**.\n\n\u003cbr /\u003e\n\n## Nginx Container\n\nFirst we are going to build a simple nginx image and\ncustomizing the html page.\n\n```Dockerfile\nFROM nginx\n\n# creating a lable\nLABEL app=nginx-example\n\n# add maintainer\nMAINTAINER amirhossein.najafizadeh21@gmail.com\n\n# setting an argument\nARG HTML_DIR=html\n\n# setting one env variable\nENV APP=\"cloud computing docker presentation\"\n\n# copy all files of html directory\nCOPY $HTML_DIR /usr/share/nginx/html\n\n# run the echo command to see directory\nRUN echo $HTML_DIR\n\n# run another command\nRUN export $APP\n\n# add a command for on build\nONBUILD RUN ls /usr/share/nginx/html\n\n# expose port 80\nEXPOSE 80/tcp\n```\n\nAs you can see, we are chaning the ```/usr/share/nginx/html``` files.\n\nSo let's build our container and start the container.\n\n```shell\ndocker build . -f build/nginx/Dockerfile --build-arg HTML_DIR=/build/nginx/html -t amirhossein21/nginx:v0.1.0\ndocker run -p 80:80 -d amirhossein21/nginx:v0.1.0\n```\n\nNow make a curl to ```localhost:8080```.\n\n## Node App\n\nIn the next example we are going to deploy a full **Node.js** application with **Redis** database on **Docker**.\n\nFirst we need to build our network and volume:\n\n#### Network\n\n```shell\ndocker network create node-app\n```\n\n#### Volume\n\n```shell\ndocker volume create redisvolume\n```\n\nNow let's start **Redis** cluster in **node-app** network, binded to ```redisvolume```.\n\n```shell\ndocker run --network=node-app -v redisvolume:/data --name node-app-redis-cluster -d redis:latest\n```\n\nNow that we have Redis cluster up and running, we are\ngoing to deploy our node app.\n\nFirst we are going to write a Dockerfile.\n\n```Dockerfile\nFROM node:16\n\n# Create app directory\nWORKDIR /usr/src/app\n\n# set environment variables\nENV HTTP_PORT=8080\nENV REDIS_URL=redis://node-app-redis-cluster:6379\n\n# Install app dependencies\n# A wildcard is used to ensure both package.json AND package-lock.json are copied\n# where available (npm@5+)\nCOPY ./app/package*.json ./\n\n# Run npm i to create node_modules directory.\nRUN npm install\n\n# If you are building your code for production\n# RUN npm ci --only=production\n\n# Bundle app source\nCOPY ./app .\n\n# cmd allows us to execute the node app starting command\nCMD [ \"node\", \"index.js\" ]\n```\n\nPay attention to the redis cluster address:\n\n```Dockerfile\nENV REDIS_URL=redis://node-app-redis-cluster:6379\n```\n\nSince our node app container and redis cluster are in\none network, we can use the redis container name insted of host ip.\n\n#### Build\n\n```shell\ndocker build . -f build/app/Dockerfile -t amirhossein21/node-app:v0.1.0\n```\n\n#### Run\n\n```shell\ndocker run --network=node-app --name node-app-container -d -p 8080:8080 amirhossein21/node-app:v0.1.0\n```\n\nNow make the following http requests:\n\n```shell\ncurl -X POST \"localhost:8080/api?key=amir\u0026value=hossein\"\ncurl -X GET \"localhost:8080/api?key=amir\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirhnajafiz-presentations%2Fdocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famirhnajafiz-presentations%2Fdocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirhnajafiz-presentations%2Fdocker/lists"}