Day16 of #90daysofdevops | Docker Introduction and basics
๐ณ Docker Introduction ๐ณ
Docker is a software platform that allows you to build, test, and deploy applications quickly. ๐ Docker packages software into standardized units called containers ๐ฆ that have everything the software needs to run including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy and scale applications into any environment and know your code will run. ๐ ๐ ๏ธ
Imagine you want to build a house (which represents your application) from scratch each time you move to a new neighborhood (server or environment). Building a house involves a lot of effort, time, and resources. However, what if you could just pack all the necessary materials and tools in a container and move them to any neighborhood? That's where Docker comes in! ๐๏ธ๐
Docker is like a container for your application. It allows you to package your application, along with all its dependencies (like libraries and configurations), into a single unit called a "Docker container." This container is lightweight and can run consistently on any environment that supports Docker, be it your local development machine, a testing server, or even a production server. ๐ฆ๐โโ๏ธ
What problem docker solves?
The main problem Docker solves is "it works on my machine." In traditional development, applications may behave differently when moved between different environments due to variations in operating systems, libraries, and configurations. This leads to compatibility issues and deployment headaches. Docker eliminates this problem by creating an isolated environment (the container) that ensures your application will run the same everywhere. ๐ค๐
Here are some key benefits Docker provides:
โ Consistency: Docker ensures that your application runs consistently across different environments, from development to production. This reduces the "it works on my machine" problem and helps streamline the development process.
โ Portability: Docker containers are self-contained units, making it easy to move and deploy them across different systems or cloud platforms. This simplifies the process of scaling your application and deploying it in various environments.
โ Isolation: Each Docker container is isolated from the host system and other containers. This isolation improves security and avoids conflicts between different applications and their dependencies.
โ Efficiency: Docker containers are lightweight and share the underlying host OS kernel, which means they require fewer resources compared to running multiple virtual machines for each application.
โ Rapid Deployment: Docker allows you to quickly deploy and update applications, as you can simply pull the pre-configured container image from a repository and run it, instead of manually setting up the entire environment.
โ Version Control: Docker enables versioning of container images, so you can roll back to previous versions if needed and have better control over the application's lifecycle.
Overall, Docker revolutionized the way applications are developed, deployed, and managed by providing a consistent and portable environment, reducing deployment friction, and promoting collaboration between development and operations teams (DevOps). ๐๐
Docker architecture :
Task(Basic commands usage)
Use the
docker run
command to start a new container and interact with it through the command line. [Hint: docker run hello-world]docker images - To check all images fetched/pull from the docker hub
docker run -it ubuntu /bin/bash - to pull an image from the docker hub
docker ps -a - process status (shows running containers)
docker start hello-world - runs the container and the same can be confirmed by docker ps
Use the
docker inspect
command to view detailed information about a container or image.docker inspect - shows the details of the container
(configuration part)Use the
docker port
command to list the port mappings for a container.docker port <container id> - to check the mapping of the port in the docker container.
Use the
docker stats
command to view resource usage statistics for one or more containers.docker stats - gives container details (more about process and cpu related)
Use the
docker top
command to view the processes running inside a container.Use the
docker save
command to save an image to a tar archive.You can use gzip to save the image file and make the backup smaller.
Use the
docker load
command to load an image from a tar archive.Load an image or repository from a tar archive (even if compressed with gzip, bzip2, or xz) from a file or STDIN. It restores both images and tags.
Thanks for reading the blog & do share them with someone in need :)
Please share your views and suggestions, they are always welcome.
See you then in the next blog.
Happy learning :)