Hey there!
Ever heard of Docker? It's like a super tool for developers that makes putting your apps in containers a breeze. Whether you're just dipping your toes into the tech world or looking to level up your Docker game, this cheat sheet is here to lend a helping hand.
First things first, we'll walk you through installing Docker, making it as smooth as butter. Then, we'll dive into managing volumes โ think of them as extra storage for your containers, handy for all your data needs.
Next up, we'll chat about handling images, which are basically like the blueprints for your apps. With Docker, you'll be whipping up these images like a pro in no time.
And finally, we'll get down to the fun stuff โ doing things with containers. We'll show you the ropes on starting, stopping, and even removing them, so you can keep your container game strong.
So, whether you're a Docker newbie or a seasoned pro, this cheat sheet has got your back. Let's dive in and make Docker your new best friend!
Happy Dockering!
Developers :)
TABLE OF CONTENTS
What is Docker?
What problems does the docker simply solves in development and deployment process?
Virtual Machine vs Docker
Install Docker
Docker images vs Containers
Docker Registries
Port Binding
-> What is Docker
A standardized unit , that has everything the application needs to run.
Virtualisation software
Make developing and deploying applications much easier
Package application with all the necessary depenedencies configuration, system tools and runtime.
-> What problems does the docker simply solves in development and deployment process?
Docker simplifies several key aspects of the development and deployment process:
Consistency across environments: Docker ensures that the development environment matches the production environment. This eliminates the "it works on my machine" problem by encapsulating the application and its dependencies into a standardized container that runs consistently across different environments.
Isolation of dependencies: Docker containers encapsulate applications and their dependencies, including libraries, frameworks, and runtime environments. This isolation prevents conflicts between different applications and allows developers to work on multiple projects with different dependencies without interference.
Portability: Docker containers are lightweight and portable, making it easy to package an application and its dependencies into a single container that can run on any Docker-enabled platform. This simplifies deployment by eliminating compatibility issues and streamlining the process of moving applications between different environments.
Scalability: Docker makes it easy to scale applications horizontally by running multiple instances of containers across multiple hosts. Containers can be quickly deployed and scaled up or down to meet changing demand, making it easier to manage and optimize resource usage.
Version control: Docker images are versioned, allowing developers to track changes to the application and its dependencies over time. This makes it easy to roll back to previous versions if needed and ensures consistency between development, testing, and production environments.
-> Virtual Machine vs Docker
Architecture:
Virtual Machines (VMs): VMs virtualize physical hardware, including a full operating system (OS) stack, such as the kernel, drivers, libraries, and applications. Each VM runs on a hypervisor, which emulates the underlying hardware and allows multiple VMs to run on a single physical machine.
Docker Containers: Containers virtualize the operating system level, enabling applications to run in isolated user-space instances called containers. Containers share the host OS kernel but encapsulate the application and its dependencies, including libraries and runtime, within the container.
Resource Utilization:
Virtual Machines (VMs): VMs require a separate OS instance for each VM, leading to higher resource overhead due to duplicating the OS kernel and other system components. Each VM consumes significant memory and storage resources.
Docker Containers: Containers are lightweight and share the host OS kernel, resulting in lower resource overhead. Containers are more efficient in terms of memory and storage utilization compared to VMs, as they only require resources for the application and its dependencies.
-> Install Docker
Go to official Docker website
Download Docker
Simply install it and get started :)
Read the documentation to get the best updated commands
-> Docker images vs Containers
Images
An executable application artifact
Includes app source code but also complete environment configuration
Add environment variables create directories ,files etc.
Can be shared easily shared and moved(just like a zip or tarfile or jar file)
Now u may be wondering what is this image ๐
-> It is basically a single file with all dependencies and configurations required to run a program. Install it and you are good to goo
Containers
Container holds the entire package that is needed to run the application. Or in other words, we can say that the image is a template and the container is a copy of that template.
The container is like a VM(it provides the environment).
Images become containers when they run on the docker engine.
Multiple containers can be run for a single image
Click here -> Docker Command Sheet
Docker Registries
A storage and distribution system for Docker images.
Official images available from applications like redis,mongo,postgres etc.
Official images are maintained by the software authors or in collaboration with the docker community.
Docker hosts one of the biggest Docker registry called Docker-Hub.
A dedicated team responsible for reviewing and publishing all content in docker official images repositories.
Simply go to Docker Hub
And whatever image you want lets suppose redis
Simply search and read the documentation and go ahead with it it as simple as that.
Port Binding
Application inside container runs in an isolated docker container.
So it cant be accessed from the browser hence we need to expose the container port to the host (the machine the container runs on)
So basically we do the port binding Binds the containers port to the host port to make the service available to the outside world
we simply run the command
docker run -d -p (port on which the service is runninng):(port u want to run) (image name):(image tag)
Basically this is the only thing u need to have to get started with Docker and rest you will learn will exploring it !!