{"id":22610903,"url":"https://github.com/sshehrozali/docker-commands","last_synced_at":"2026-02-14T13:01:16.702Z","repository":{"id":119424509,"uuid":"569153575","full_name":"sshehrozali/docker-commands","owner":"sshehrozali","description":"Get started Docker guide for beginners 🐳.","archived":false,"fork":false,"pushed_at":"2022-11-24T09:55:48.000Z","size":5,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T23:03:51.897Z","etag":null,"topics":["docker","docker-image","docker-network","docker-tutorial"],"latest_commit_sha":null,"homepage":"","language":null,"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/sshehrozali.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":"2022-11-22T07:43:32.000Z","updated_at":"2023-04-07T10:23:59.000Z","dependencies_parsed_at":"2023-03-16T13:30:21.923Z","dependency_job_id":null,"html_url":"https://github.com/sshehrozali/docker-commands","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sshehrozali/docker-commands","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshehrozali%2Fdocker-commands","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshehrozali%2Fdocker-commands/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshehrozali%2Fdocker-commands/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshehrozali%2Fdocker-commands/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sshehrozali","download_url":"https://codeload.github.com/sshehrozali/docker-commands/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshehrozali%2Fdocker-commands/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29444021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T12:43:28.304Z","status":"ssl_error","status_checked_at":"2026-02-14T12:43:14.160Z","response_time":53,"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","docker-image","docker-network","docker-tutorial"],"created_at":"2024-12-08T16:08:28.056Z","updated_at":"2026-02-14T13:01:16.685Z","avatar_url":"https://github.com/sshehrozali.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"## Docker Commands\n### Quick Start Guide\n\n#### Container vs Image\nA Docker Image is a file that contains the actual binaries such as PostgresSQL, Redis, etc. It's the same as installing it directly on the machine.\n\nA Docker Container is actually a virtual environment which has all the configurations installed i.e. original image, setting up environment, required libraries, protocol/network configuration, and everything in order to make the Docker image executable.\n\n#### Docker Network\nA Docker Network is a virtually created network environment where you can run your Docker containers inside (like a isolated piece of containers running in a specified Docker network).\n\nExample can be:\n1. Creating a `mongo-network`\n2. Pulling `mongodb` and `mongoexpress` Docker images\n3. Running both images in their containers inside mongo-network (specifying by passing a flag arg)\n4. `mongodb` and `mongoexpress` now running inside `mongo-network`\n\n#### Port Binding\nDocker port binding is a technique to allow multiple Docker images listen to their respective ports even if they both running on same ports. This is done via port binding command.\n\n##### How it works?\nWe bind every Docker image port to listen to their respective HOST (each HOST cannot have some ports shared). \n\nYou can think port binding like this:\n`... -p PORT:HOST ...` where `PORT` is actual the port where your Docker image is listening to and `HOST` is your machine port bound with Docker image `PORT`.\n\nThis technique is very useful especially when you running two same Docker containers with different versions like PostgesSQL v14.XX and PostgresSQL \u003c v14.XX because both PostgresSQL containers will listen to exact same port which you can't decide which container to connect. Under such scenarios port binding plays a very useful technique.\n\n### Commands\n\n#### Containerization\n* `docker pull [image]` - to pull image from Docker Hub\n* `docker run [image]` - to start a Docker container\n* `docker run [flags] [image]` - to start a Docker container with flags\n* `docker start [container_id]` - to restart a Docker container\n* `docker stop [container_id]` - to stop a Docker container\n* `docker build -t [container_name]:[version]` - to build an image with a Dockerfile\n* `docker rm [container_id]` - to remove a container\n\n#### Images\n* `docker images` - to list all Docker images\n* `docker push [image_name]:version` - to push a Docker image to Docker registry or any private Docker repository (AWS ECR, etc.)\n* `docker tag -a [current_image_name] [new_image_name]` - to rename a Docker image\n\n#### Logs\n* `docker ps -a` - to get history of all ended/up containers\n* `docker ps -a | grep [container_name]` - to see history of a specific container\n* `docker ps` - to list all running containers\n* `docker logs [container_id] or [container_name]`- to display logs of running container\n* `docker exec -it [container_id] /bin/bash` - to get access as a root user for Bash\n* `docker exec -it [container_id] /bin/sh` - to get access as a root user for Shell\n\n#### Example use-case for starting mongodb container\n`docker run -d \\\n--name mongodb \\\n-p 27017:27017 \\\n-e MONGO-INITDB_ROOT_USERNAME=admin \\\nMONGO-INITDB_ROOT_PASSWORD=password \\\n--net mongo-network \\\nmongo`\n\nFlags:\n* d: Start in detach mode\n* name: Name of the container\n* p: Port binding\n* e: Environment variables\n* net: Specifying which network to run in\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshehrozali%2Fdocker-commands","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsshehrozali%2Fdocker-commands","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshehrozali%2Fdocker-commands/lists"}