{"id":24569090,"url":"https://github.com/ryomendev/docker","last_synced_at":"2025-10-14T03:34:26.580Z","repository":{"id":271853637,"uuid":"914376433","full_name":"RyomenDev/Docker","owner":"RyomenDev","description":"Comprehensive Docker learning repository with essential commands, practical examples, and ready-to-use code snippets. Ideal for beginners and professionals to master containerization, streamline development workflows, and enhance deployment efficiency. Start your Docker journey here!","archived":false,"fork":false,"pushed_at":"2025-01-17T13:57:11.000Z","size":219,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T10:54:41.600Z","etag":null,"topics":["container","docker","docker-image","dockerfile","python","template"],"latest_commit_sha":null,"homepage":"","language":"Starlark","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/RyomenDev.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":"2025-01-09T13:30:03.000Z","updated_at":"2025-01-17T13:57:12.000Z","dependencies_parsed_at":"2025-01-17T14:47:43.428Z","dependency_job_id":null,"html_url":"https://github.com/RyomenDev/Docker","commit_stats":null,"previous_names":["ryomendev/docker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RyomenDev/Docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyomenDev%2FDocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyomenDev%2FDocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyomenDev%2FDocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyomenDev%2FDocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RyomenDev","download_url":"https://codeload.github.com/RyomenDev/Docker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyomenDev%2FDocker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017767,"owners_count":26086145,"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-10-14T02:00:06.444Z","response_time":60,"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","docker-image","dockerfile","python","template"],"created_at":"2025-01-23T14:56:14.404Z","updated_at":"2025-10-14T03:34:26.553Z","avatar_url":"https://github.com/RyomenDev.png","language":"Starlark","readme":"\n\n\n## What is a container ?\n\nA container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.\n\nOk, let me make it easy !!!\n\nA container is a bundle of Application, Application libraries required to run your application and the minimum system dependencies.\n\n![Screenshot 2023-02-07 at 7 18 10 PM](https://user-images.githubusercontent.com/43399466/217262726-7cabcb5b-074d-45cc-950e-84f7119e7162.png)\n\n\n\n## Containers vs Virtual Machine \n\nContainers and virtual machines are both technologies used to isolate applications and their dependencies, but they have some key differences:\n\n    1. Resource Utilization: Containers share the host operating system kernel, making them lighter and faster than VMs. VMs have a full-fledged OS and hypervisor, making them more resource-intensive.\n\n    2. Portability: Containers are designed to be portable and can run on any system with a compatible host operating system. VMs are less portable as they need a compatible hypervisor to run.\n\n    3. Security: VMs provide a higher level of security as each VM has its own operating system and can be isolated from the host and other VMs. Containers provide less isolation, as they share the host operating system.\n\n   4.  Management: Managing containers is typically easier than managing VMs, as containers are designed to be lightweight and fast-moving.\n\n\n\n## Why are containers light weight ?\n\nContainers are lightweight because they use a technology called containerization, which allows them to share the host operating system's kernel and libraries, while still providing isolation for the application and its dependencies. This results in a smaller footprint compared to traditional virtual machines, as the containers do not need to include a full operating system. Additionally, Docker containers are designed to be minimal, only including what is necessary for the application to run, further reducing their size.\n\nLet's try to understand this with an example:\n\nBelow is the screenshot of official ubuntu base image which you can use for your container. It's just ~ 22 MB, isn't it very small ? on a contrary if you look at official ubuntu VM image it will be close to ~ 2.3 GB. So the container base image is almost 100 times less than VM image.\n\n![Screenshot 2023-02-08 at 3 12 38 PM](https://user-images.githubusercontent.com/43399466/217493284-85411ae0-b283-4475-9729-6b082e35fc7d.png)\n\n\nTo provide a better picture of files and folders that containers base images have and files and folders that containers use from host operating system (not 100 percent accurate -\u003e varies from base image to base image). Refer below.\n\n\n\n### Files and Folders in containers base images\n\n```\n    /bin: contains binary executable files, such as the ls, cp, and ps commands.\n\n    /sbin: contains system binary executable files, such as the init and shutdown commands.\n\n    /etc: contains configuration files for various system services.\n\n    /lib: contains library files that are used by the binary executables.\n\n    /usr: contains user-related files and utilities, such as applications, libraries, and documentation.\n\n    /var: contains variable data, such as log files, spool files, and temporary files.\n\n    /root: is the home directory of the root user.\n```\n\n\n\n### Files and Folders that containers use from host operating system\n\n```\n    The host's file system: Docker containers can access the host file system using bind mounts, which allow the container to read and write files in the host file system.\n\n    Networking stack: The host's networking stack is used to provide network connectivity to the container. Docker containers can be connected to the host's network directly or through a virtual network.\n\n    System calls: The host's kernel handles system calls from the container, which is how the container accesses the host's resources, such as CPU, memory, and I/O.\n\n    Namespaces: Docker containers use Linux namespaces to create isolated environments for the container's processes. Namespaces provide isolation for resources such as the file system, process ID, and network.\n\n    Control groups (cgroups): Docker containers use cgroups to limit and control the amount of resources, such as CPU, memory, and I/O, that a container can access.\n    \n```\n\nIt's important to note that while a container uses resources from the host operating system, it is still isolated from the host and other containers, so changes to the container do not affect the host or other containers.\n\n**Note:** There are multiple ways to reduce your VM image size as well, but I am just talking about the default for easy comparision and understanding.\n\nso, in a nutshell, container base images are typically smaller compared to VM images because they are designed to be minimalist and only contain the necessary components for running a specific application or service. VMs, on the other hand, emulate an entire operating system, including all its libraries, utilities, and system files, resulting in a much larger size. \n\nI hope it is now very clear why containers are light weight in nature.\n\n\n\n## Docker\n\n\n### What is Docker ?\n\nDocker is a containerization platform that provides easy way to containerize your applications, which means, using Docker you can build container images, run the images to create containers and also push these containers to container regestries such as DockerHub, Quay.io and so on.\n\nIn simple words, you can understand as `containerization is a concept or technology` and `Docker Implements Containerization`.\n\n\n### Docker Architecture ?\n\n![image](https://user-images.githubusercontent.com/43399466/217507877-212d3a60-143a-4a1d-ab79-4bb615cb4622.png)\n\nThe above picture, clearly indicates that Docker Deamon is brain of Docker. If Docker Deamon is killed, stops working for some reasons, Docker is brain dead :p (sarcasm intended).\n\n### Docker LifeCycle \n\nWe can use the above Image as reference to understand the lifecycle of Docker.\n\nThere are three important things,\n\n1. docker build -\u003e builds docker images from Dockerfile\n2. docker run   -\u003e runs container from docker images\n3. docker push  -\u003e push the container image to public/private regestries to share the docker images.\n\n![Screenshot 2023-02-08 at 4 32 13 PM](https://user-images.githubusercontent.com/43399466/217511949-81f897b2-70ee-41d1-b229-38d0572c54c7.png)\n\n\n\n### Understanding the terminology (Inspired from Docker Docs)\n\n\n#### Docker daemon\n\nThe Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.\n\n\n#### Docker client\n\nThe Docker client (docker) is the primary way that many Docker users interact with Docker. When you use commands such as docker run, the client sends these commands to dockerd, which carries them out. The docker command uses the Docker API. The Docker client can communicate with more than one daemon.\n\n\n#### Docker Desktop\n\nDocker Desktop is an easy-to-install application for your Mac, Windows or Linux environment that enables you to build and share containerized applications and microservices. Docker Desktop includes the Docker daemon (dockerd), the Docker client (docker), Docker Compose, Docker Content Trust, Kubernetes, and Credential Helper. For more information, see Docker Desktop.\n\n\n#### Docker registries\n\nA Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured to look for images on Docker Hub by default. You can even run your own private registry.\n\nWhen you use the docker pull or docker run commands, the required images are pulled from your configured registry. When you use the docker push command, your image is pushed to your configured registry.\nDocker objects\n\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#### Dockerfile\n\nDockerfile is a file where you provide the steps to build your Docker Image. \n\n\n#### Images\n\nAn image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization. For example, you may build an image which is based on the ubuntu image, but installs the Apache web server and your application, as well as the configuration details needed to make your application run.\n\nYou might create your own images or you might only use those created by others and published in a registry. To build your own image, you create a Dockerfile with a simple syntax for defining the steps needed to create the image and run it. Each instruction in a Dockerfile creates a layer in the image. When you change the Dockerfile and rebuild the image, only those layers which have changed are rebuilt. This is part of what makes images so lightweight, small, and fast, when compared to other virtualization technologies.\n\n\n\n## INSTALL DOCKER\n\nA very detailed instructions to install Docker are provide in the below link\n\nhttps://docs.docker.com/get-docker/\n\nFor Demo, \n\nYou can create an Ubuntu EC2 Instance on AWS and run the below commands to install docker.\n\n```\nsudo apt update\nsudo apt install docker.io -y\n```\n\n\n### Start Docker and Grant Access\n\nA very common mistake that many beginners do is, After they install docker using the sudo access, they miss the step to Start the Docker daemon and grant acess to the user they want to use to interact with docker and run docker commands.\n\nAlways ensure the docker daemon is up and running.\n\nA easy way to verify your Docker installation is by running the below command\n\n```\ndocker run hello-world\n```\n\nIf the output says:\n\n```\ndocker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post \"http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create\": dial unix /var/run/docker.sock: connect: permission denied.\nSee 'docker run --help'.\n```\n\nThis can mean two things, \n1. Docker deamon is not running.\n2. Your user does not have access to run docker commands.\n\n\n### Start Docker daemon\n\nYou use the below command to verify if the docker daemon is actually started and Active\n\n```\nsudo systemctl status docker\n```\n\nIf you notice that the docker daemon is not running, you can start the daemon using the below command\n\n```\nsudo systemctl start docker\n```\n\n\n### Grant Access to your user to run docker commands\n\nTo grant access to your user to run the docker command, you should add the user to the Docker Linux group. Docker group is create by default when docker is installed.\n\n```\nsudo usermod -aG docker ubuntu\n```\n\nIn the above command `ubuntu` is the name of the user, you can change the username appropriately.\n\n**NOTE:** : You need to logout and login back for the changes to be reflected.\n\n\n### Docker is Installed, up and running 🥳🥳\n\nUse the same command again, to verify that docker is up and running.\n\n```\ndocker run hello-world\n```\n\nOutput should look like:\n\n```\n....\n....\nHello from Docker!\nThis message shows that your installation appears to be working correctly.\n...\n...\n```\n\n\n## Great Job, Now start with the examples folder to write your first Dockerfile and move to the next examples. Happy Learning :)\n\n### Clone this repository and move to example folder\n\n```\ncd  examples\n```\n\n### Login to Docker [Create an account with https://hub.docker.com/]\n\n```\ndocker login\n```\n\n```\nLogin with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.\nUsername: repo_name\nPassword:\nWARNING! Your password will be stored unencrypted in /home/ubuntu/.docker/config.json.\nConfigure a credential helper to remove this warning. See\nhttps://docs.docker.com/engine/reference/commandline/login/#credentials-store\n\nLogin Succeeded\n```\n\n### Build your first Docker Image\n\nYou need to change the username accoringly in the below command\n\n```\ndocker build -t repo_name/my-first-docker-image:latest .\n```\n\nOutput of the above command\n\n```\n    Sending build context to Docker daemon  992.8kB\n    Step 1/6 : FROM ubuntu:latest\n    latest: Pulling from library/ubuntu\n    677076032cca: Pull complete\n    Digest: sha256:9a0bdde4188b896a372804be2384015e90e3f84906b750c1a53539b585fbbe7f\n    Status: Downloaded newer image for ubuntu:latest\n     ---\u003e 58db3edaf2be\n    Step 2/6 : WORKDIR /app\n     ---\u003e Running in 630f5e4db7d3\n    Removing intermediate container 630f5e4db7d3\n     ---\u003e 6b1d9f654263\n    Step 3/6 : COPY . /app\n     ---\u003e 984edffabc23\n    Step 4/6 : RUN apt-get update \u0026\u0026 apt-get install -y python3 python3-pip\n     ---\u003e Running in a558acdc9b03\n    Step 5/6 : ENV NAME World\n     ---\u003e Running in 733207001f2e\n    Removing intermediate container 733207001f2e\n     ---\u003e 94128cf6be21\n    Step 6/6 : CMD [\"python3\", \"app.py\"]\n     ---\u003e Running in 5d60ad3a59ff\n    Removing intermediate container 5d60ad3a59ff\n     ---\u003e 960d37536dcd\n    Successfully built 960d37536dcd\n    Successfully tagged repo_name/my-first-docker-image:latest\n```\n\n### Verify Docker Image is created\n\n```\ndocker images\n```\n\nOutput \n\n```\nREPOSITORY                         TAG       IMAGE ID       CREATED          SIZE\nrepo_name/my-first-docker-image   latest    960d37536dcd   26 seconds ago   467MB\nubuntu                             latest    58db3edaf2be   13 days ago      77.8MB\nhello-world                        latest    feb5d9fea6a5   16 months ago    13.3kB\n```\n\n### Run your First Docker Container\n\n```\ndocker run -it repo_name/my-first-docker-image\n```\n\nOutput\n\n```\nHello World\n```\n\n### Push the Image to DockerHub and share it with the world\n\n```\ndocker push repo_name/my-first-docker-image\n```\n\nOutput\n\n```\nUsing default tag: latest\nThe push refers to repository [docker.io/repo_name/my-first-docker-image]\n896818320e80: Pushed\nb8088c305a52: Pushed\n69dd4ccec1a0: Pushed\nc5ff2d88f679: Mounted from library/ubuntu\nlatest: digest: sha256:6e49841ad9e720a7baedcd41f9b666fcd7b583151d0763fe78101bb8221b1d88 size: 1157\n```\n\nYou can watch the video version of this repo on youtube playlist. -\u003e https://www.youtube.com/watch?v=7JZP345yVjw\u0026list=PLdpzxOOAlwvLjb0vTD9BXLOwwLD_GWCmC","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryomendev%2Fdocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryomendev%2Fdocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryomendev%2Fdocker/lists"}