If you’re a programmer or techie, you have setup for all your need software in your machine. So it difficult, all software needed depending OS and run applications. Now you can install the only docker and run all need applications in docker without depending os and also docker you can install on Windows, Linux, Mac, Cloud, Serverless, etc. so now you have all question what is docker?
Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Now in your mind say what is the container?
A container is a standard unit of software that packages up a code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
“In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they’re running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application.”
Difference Between Docker and VM (Virtual Machine)
multiple containers can run on the same machine and share os kernel with other containers. each running as isolated processes in userspace. and also container take up less space then VM’s.
The Hypervisor is Allow Multiple VM run on a single machine. Each VM includes a full copy of an OS and the VM is use much memory. VM can also be slow to boot.
Docker, The Good Things
- Fast Boot:Takes seconds to start a container, so you need to restart or deploy new versions, your new instance is up in second.
- The container uses less Resource:since you don’t have a full OS and they all share the same kernel, they are lightweight.
- The containers are small better than VM:They start from then of Megabytes Up, Where VMs start from Gigabytes. so you current server can host way more container.
Docker’s native platform is Linux, as it’s based on features provided by the Linux kernel. However, you can still run it on macOS and windows. the only difference is that on macOS and Windows, Docker is encapsulated into a tiny virtual machine.
You can check out the installation instructions for Docker here.
- Image — the basic element for every container. When you create an image, every step is cached and can be reused. Depending on the image, it can take some time to build. Containers, on the other hand, can be started from images right away.
- Container— a running instance that encapsulates the required software. Containers are always created from images. A container can expose ports and volumes to interact with other containers or/and the outer world.
- Port— a TCP/UDP port in its original meaning. To keep things simple, let’s assume that ports can be exposed to the outer world.
- Volume— can be described as a shared folder. Volumes are initialized when a container is created. Volumes are designed to persist data, independent of the container’s lifecycle.
Example 1. Redis Install in Docker
It’s time to run your first container:
“First Pull Image in Docker:
docker pull redis
Check List Of Images Command:
- Start a Redis instance: docker run –name redisContainer -d redis — name : name of container -d : it is image name you pull in docker.
- Alternate add Port to access outside of container:
docker run –name redisContainer -p 6379:6379 -d redis
-p: add port number you can access out side of container
“check run container in docker: