{"id":20383261,"url":"https://github.com/praem90/docker-introduction","last_synced_at":"2025-10-17T00:45:52.266Z","repository":{"id":199436169,"uuid":"702883511","full_name":"praem90/docker-introduction","owner":"praem90","description":"An introduction to Docker for beginners","archived":false,"fork":false,"pushed_at":"2023-10-11T05:23:42.000Z","size":113,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T22:44:05.620Z","etag":null,"topics":["container","docker","images","network","port"],"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/praem90.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":"2023-10-10T07:36:43.000Z","updated_at":"2023-10-10T07:42:58.000Z","dependencies_parsed_at":"2023-12-13T08:45:10.701Z","dependency_job_id":null,"html_url":"https://github.com/praem90/docker-introduction","commit_stats":null,"previous_names":["praem90/docker-introduction"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/praem90/docker-introduction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praem90%2Fdocker-introduction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praem90%2Fdocker-introduction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praem90%2Fdocker-introduction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praem90%2Fdocker-introduction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/praem90","download_url":"https://codeload.github.com/praem90/docker-introduction/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praem90%2Fdocker-introduction/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274046000,"owners_count":25212982,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"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":["container","docker","images","network","port"],"created_at":"2024-11-15T02:21:42.699Z","updated_at":"2025-10-17T00:45:47.223Z","avatar_url":"https://github.com/praem90.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker\n\n## Topics\n * What is Docker?\n * Why do we need Docker?\n * Key components of a Docker\n * Image\n * Container\n * Network\n * Volume\n\n---\n\n## What is Docker?\n - Docker is an open-source software platform that enables developers to build, deploy, run, update, and manage containers.\n - Docker uses OS-level virtualization to deliver software in packages called containers.\n - Docker standardized executable components that combine application source code with\n   the operating system libraries and dependencies required to run that code in any *environment*.\n\n---\n\n## Why do we need Docker?\n - Docker enables you to separate your applications from your infrastructure so you can deliver software quickly.\n - Docker's container-based platform allows for highly portable workloads.\n - Docker containers can run on a developer's local laptop, on physical or virtual machines in a data center, on cloud providers, or in a mixture of environments.\n - Docker's portability and lightweight nature also make it easy to dynamically manage workloads, scaling up or tearing down applications and services as business needs dictate, in near real time.\n\n---\n\n## Questions\n\n Any questions?\n\n---\n\n## Docker Objects\nWhen you use Docker, you are creating and using images, containers, networks, volumes, plugins, and other objects. This section is a brief overview of some of those objects.\n\n---\n\n### Images\n - An image is a read-only template with instructions for creating a Docker container.\n - Often, an image is based on another image, with some additional customization.\n - For example, you may build an image which is based on the ubuntu image, but installs the Apache web server\n - and your application, as well as the configuration details needed to make your application run.\n - You might create your own images or you might only use those created by others and published in a registry.\n\nAn image is like a class. It is just a blueprint with set of instructions to create a container.\n\n|Class       | Image/Dockerfile |\n|:----------:|:----------------:|\n| Class Car {                    |FROM ubuntu    |\n|    private wheels;            | RUN apt-get install nginx |\n|    private steering;          |\n|    private fuel;              |\n|                               |\n|    public function move() {   |\n|    }                          |\n| }                             |\n\n\n---\n\n### Container\n- A container is a runnable instance of an image.\n- You can create, start, stop, move, or delete a container using the Docker API or CLI.\n- You can create multiple containers using the same image\n\n| Instance | Container |\n|:--------:|:---------:|\n| $car = new Car() | docker run ubuntu |\n\n```bash\n docker run bash:latest bash -c \"date \u003e file.txt \u0026\u0026 cat file.txt\"\n```\n\n---\n\n## Questions\n\n Any Questions?\n\n---\n\n### Network\n - Container networking refers to the ability for containers to connect to and communicate with each other, or to non-Docker workloads.\n - By default, when you create or run a container using docker create or docker run, the container doesn't expose any of its ports to the outside world.\n - Use the --publish or -p flag to make a port available to services outside of Docker.\n - This creates a firewall rule in the host, mapping a container port to a port on the Docker host to the outside world.\n\n---\n\n#### Port\n```bash\ndocker run nginx\ndocker ps\n```\n\nYou wont be able to access the nginx server http://localhost\n\n```bash\ndocker run -p 80:80 nginx\ndocker ps\n```\n\nNow we will be able to access the nginx server via http://localhost:80\n\n```bash\ndocker run -p 8989:80 nginx\ndocker ps\n```\n\nWe can bind different port for host machine.\nDocker will act as proxy and serves the data.\n\nNow we wont be able to access via port 80 but http://localhost:8989\n\n---\n\n#### Network Drivers\n - Docker's networking subsystem is pluggable, using drivers. Several drivers exist by default, and provide core networking functionality.\n    * bridge // the default network driver\n    * host\n    * overlay\n    * ipvlan\n    * macvlan\n    * none\n\n```bash\ndocker run bash bash -c \"wget http://localhost:80\"\n```\nNginx wont be accessible from the bash container.\nthe localhost refers to the same bash container not the nginx container.\nThe nginx container has its own ip inside the network\n\n```bash\ndocker run --network=bridge -d nginx\ndocker container inspect 'name_of_the_container' | grep IPAddress\ndocker run --network=bridge bash bash -c \"wget http://ip_address_of_the_nginx_container:80\"\n```\n\n---\n\n### Volume\n - While containers can create, update, and delete files, those changes are lost when you remove the container and Docker isolates all changes to that container.\n - With volumes, you can change all of this.\n - Volumes provide the ability to connect specific filesystem paths of the container back to the host machine.\n - If you mount a directory in the container, changes in that directory are also seen on the host machine.\n - If you mount that same directory across container restarts, you'd see the same files.\n\n E.g:\n Did you able to get the `file.txt` from the above command\n\n ```bash\n docker run -it bash:latest bash -c \"date \u003e file.txt \u0026\u0026 cat file.txt \u0026\u0026 bash\"\n docker run -it -w /app -v $(pwd):/app bash:latest bash -c \"date \u003e file.txt \u0026\u0026 cat file.txt \u0026\u0026 bash\"\n ```\n Now you can see the files in this host folder will be available in the containers `/app` directory and vice versa.\n There are different types of volume and different ways to mount a volume to a container.\n\n ---\n\n## Questions\n\n Any Questions?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpraem90%2Fdocker-introduction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpraem90%2Fdocker-introduction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpraem90%2Fdocker-introduction/lists"}