{"id":15701098,"url":"https://github.com/harshkapadia2/docker","last_synced_at":"2025-07-24T20:33:51.296Z","repository":{"id":135897366,"uuid":"319375917","full_name":"HarshKapadia2/docker","owner":"HarshKapadia2","description":"Resources and commands for Docker.","archived":false,"fork":false,"pushed_at":"2023-06-18T01:23:53.000Z","size":31,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T23:39:13.717Z","etag":null,"topics":["docker"],"latest_commit_sha":null,"homepage":"https://harshkapadia2.github.io/docker","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HarshKapadia2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-12-07T16:18:47.000Z","updated_at":"2023-02-24T09:52:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"f524f46c-a586-4a41-af96-3180e666a963","html_url":"https://github.com/HarshKapadia2/docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshKapadia2%2Fdocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshKapadia2%2Fdocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshKapadia2%2Fdocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshKapadia2%2Fdocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HarshKapadia2","download_url":"https://codeload.github.com/HarshKapadia2/docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253764648,"owners_count":21960602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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"],"created_at":"2024-10-03T19:59:39.306Z","updated_at":"2025-05-12T15:25:54.574Z","avatar_url":"https://github.com/HarshKapadia2.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker\n\n## Table of Contents\n\n-   [Introduction](#introduction)\n-   [Linux and Networking](#linux-and-networking)\n-   [Commands](#commands)\n    -   [Miscellaneous Commands](#miscellaneous-commands)\n    -   [Images](#images)\n    -   [Containers](#containers)\n    -   [Bind Mount](#bind-mount)\n-   [Resources](#resources)\n\n## Introduction\n\n-   Crash course\n    -   [Exploring Docker [1] - Getting Started](https://www.youtube.com/watch?v=Kyx2PsuwomE)\n    -   [Exploring Docker [2] - Docker Compose With Node \u0026 MongoDB](https://www.youtube.com/watch?v=hP77Rua1E0c)\n-   [Docker in 100 secs](https://www.youtube.com/watch?v=Gjnup-PuquQ)\n-   Aim: To run software services/progs/applications inside containers.\n-   Eg: Apache, MySQL, MongoDB, NginX (web server common to Apache), Wordpress, etc...\n-   Advantages: Convenient, fast, simple, easy to re-create the same environment.\n-   [Docker Hub](https://hub.docker.com) == GitHub of Docker\n\n\u003e NOTE:\n\u003e\n\u003e -   [Docker Desktop for Windows Home is here!](https://www.docker.com/blog/docker-desktop-for-windows-home-is-here)\n\u003e -   For Win 10 Home (2004 and above), Pro and Enterprise, install Docker Desktop.\n\u003e -   For Win 10 Home 1909 and lower, install Docker Toolkit.\n\u003e -   Docker might not work on VSCode integrated terminal. In that case, open VSCode as an administrator, use ext cmd or use powershell.\n\u003e -   Some commands might not work in cmd. Use Powershell in that case.\n\u003e -   [`$(pwd)` in MacOS is `$(%cd%)` in Cmd and `${PWD}` in Powershell](https://stackoverflow.com/questions/41485217/mount-current-directory-as-a-volume-in-docker-on-windows-10)\n\u003e -   `localhost:port` might not work. Use `198.168.99.100:port` instead.\n\u003e -   Container privileges\n\u003e     -   [Network privileges might be required sometimes](https://unix.stackexchange.com/questions/459206/list-ip-tables-in-docker-container)\n\u003e     -   [All privileges](https://stackoverflow.com/questions/36425230/privileged-containers-and-capabilities)\n\n## Linux and Networking\n\nPlease refer to [linux-networking.md](linux-networking.md).\n\n## Commands\n\n### Miscellaneous Commands\n\n-   `docker version`\n-   Server: Docker Engine (built on Go lang)\n-   `docker info`\n\n### Images\n\n-   To view images on local machine: `docker images`\n-   To remove images: `docker image rm ed2` (the entire image ID is not required)\n-   To pull image from DockerHub: `docker pull nginx`\n-   To build image\n    -   `docker image build -t harshkapadia/nginx-website .`\n        -   `harshkapadia/nginx-website` = Docker_ID/img_name\n        -   `.` = refering to Dockerfile in currect dir (make sure your cmd is pointing to the correct folder)\n-   To push image to DockerHub: `docker push harshkapadia/nginx-website`\n\n### Containers\n\n-   To show running containers\n    -   `docker container ls`\n    -   `docker container ps`\n    -   `docker ps`\n-   To show all containers on the system\n    -   `docker container ls -a`\n    -   `docker ps -a`\n-   To run container in the foreground\n    -   `docker container run -it -p 80:80 --name my_custom_name_for_nginx nginx`\n        -   `container` = management command\n        -   `run` = sub-command\n        -   `it` = interactive terminal, ie, run in the foreground\n        -   `-p` or `--publish` = publish\n        -   `80:80` = mapping ports (port*to_be_used_on_local_machine*(use*any_port):port_exposed_from_container*- (use_default_port_of_service_in_container))\n        -   `nginx` = image name\n    -   Once the img is downloaded:\n        -   `localhost:80` or `localhost` (default is 80) or `127.0.0.1` (localhost)\n        -   Win 10 Home users (might not be needed with Docker Desktop): `192.168.99.100` (Since Toolbox is running a Linux VM in VirtualBox, localhost won't work. Use `192.168.99.100` (default) instead.)\n    -   To stop container: \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003ec\u003c/kbd\u003e\n-   To run container in the background:\n    -   `docker container run -d -p 8080:80 --name my_custom_name_for_nginx nginx`\n        -   `-d` or `--detach` = detached\n    -   To stop container: `docker stop my_custom_name_for_nginx` or `docker container stop my_custom_name_for_nginx`\n    -   To view:\n        `192.168.99.100:8080` (Win 10 Home users - might not be needed with Docker Desktop - `localhost` might work)\n-   To remove container: `docker container rm c699` (the entire container ID is not required) (deleting container does not remove the image from the system)\n-   To remove running container:\n    -   First stop the container and use the remove command\n    -   OR use force: `docker container rm c699 -f`\n-   To remove all containers on the system: `docker rm $(docker ps -aq) -f` (`-f` added to remove any running container(s) as well) (this ran in powershell, but not in cmd)\n-   Env variables: `docker container run -d -p 3306:3306 --name my_sql_user --env MYSQL_ROOT_PASSWORD=123456 mysql` (you can find the env vars on Docker Hub)\n-   To start a new container from an existing image: `docker container run -d -p 80:80 --name custom_name_nginx nginx`\n-   To start an existing container: `docker start \u003ccontainer_id\u003e`\n-   To enter a container: `docker container exec -it mynginx bash` (start the container using the abv cmd before doing this)\n    -   After entering:\n        -   To view file system: `ls`\n        -   To get to index.html (displayed on screen at port) (for nginx): `cd usr/share/nginx/html`\n        -   To come out of container: `exit`\n        -   To edit file, refer to the bind mount section below.\n\n### Bind Mount\n\n\u003e NOTE: Ports 80 or 8081 might not work with below example. Use 8080, 8082, 8083...\n\n-   To create container:\n    -   With Docker Toolbox:\n        -   Refer to [`bind_mount.md`](bind_mount.md) for further details on 'x_drive'.\n        -   Make sure docker-machine is running (`docker-machine start`)\n        -   `docker container run -d -p 8080:80 -v /x_drive/coding/docker/docker_basics/mounting_example:/usr/share/nginx/html --name - nginx-website nginx`\n        -   Refer to files in the [`mounting_example`](mounting_example) folder.\n    -   With Docker Desktop:\n        `docker container run -it -v \"%cd%\":/mnt --name kali kalilinux/kali-rolling`\n\n## Resources\n\n-   [Understanding Docker layers](https://devops.stackexchange.com/questions/1750/understanding-docker-layers)\n-   [Networking in a Linux Container in Docker](linux-networking.md)\n-   [Linux file system](https://gist.github.com/HarshKapadia2/18150e1e57eab1f0e500f18feea890aa)\n-   [Linux Terminal commands](https://harshkapadia2.github.io/cli)\n-   [Windows Subsystem for Linux](https://gist.github.com/HarshKapadia2/714bba15f0f09d32c07cdde3c244be9f) (WSL)\n-   [Windows Terminal](https://gist.github.com/HarshKapadia2/18daf23ab4a7d1cb9215ca9dc8b7099f) (WT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshkapadia2%2Fdocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharshkapadia2%2Fdocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshkapadia2%2Fdocker/lists"}