joplin-notes/joplin notion extension/Web Development/Extras/Docker/Containers.md
2026-11-04 00:33:23 +05:30

2.4 KiB

Containers

A container is a unit of deployment. It contains everything for a code to run. We take the container, push them on server and it should run. Container contains code, runtime, system tools and system libraries. It can have external dependencies too like database or cache

Reason of using container

  • Move faster by deploying smaller units
  • Use few resources
  • Fit more into the same host
  • Faster automation when using CI/CD techniques
  • Portability
  • Isolation

Virtual machine vs containers

  • VM runs on hardware where OS is installed. OS hypervisor lets us create virtual machine where we install an OS . So we would have bios and firmware too as it is hardware even though it is virtual. VM is basically virtualize the hardware
  • In containers we still have hardware and OS. Container runtime is installed in the OS instead of creating virtual machine.Container images are run in the memory. Container dont need to boot as it uses the HOST kernel and they dont have to boot. They will need small disk space as there is no OS with few megabytes of hard disk and 64 or 128MB of RAM required. 1676a37516bad6609caceb44553e4ad9.png d8041f9ddaf662c8a6dda065e2b7e6ff.png    

More

Containers are made up of layers b0b2e7e0b4a84a18e328a6a58da63379.png Eg : docker pull command will download container image and each layer will be downloaded individually and each layer has unique id. If a layer already exist then it wont download again as docker uses local cache to store container's images. Advantage is if we download version 2 then it wont download whole image, just the layers which is not present So a goal is to create docker container images which smallest number of layers possible Layers in the docker : Top one is both read-write but lower ones in read-only.  

Container registry

  • Centralized container repository
  • Think Github but for containers.
  • Docker hub is a great example
  • Major providers have container registry services like AWS, azure and GCP.  

Orchestrator

  • Allow us to Manage, scale monitor the containers that we run on servers
  • We can use our own like kubernates, swarm, service fabric
  • or we can use a managed cluster offered by cloud providers.