What is Docker?
Docker is a platform for packaging, deploying and running applications.
Docker applications run in containers that can be used on any system: a developer’s laptop, desktop, VM, Cloud etc.
It packages applications as images that contain everything needed to run them: Code, Runtime environment, Libraries and Configuration.
A running instance of a docker image is called a docker container.
Docker containers don’t run in their own virtual machines, but share a Linux kernel. Compared to virtual machines, containers use less memory and less CPU.
However, a Linux runtime is required for Docker. Implementations on non-Linux platforms such as macOS and Windows 10 use a single Linux virtual machine. The containers share this system.
Why Docker Containers?
- Footprint: 100-1000 containers on one machine
- Small Disk/CPU requirements as compared to VM’s
- Supported by all Cloud providers
- Speed: Boots in seconds
- Isolation and encapsulation of application dependencies.
- Ability to scale efficiently, easily, and in real time.
- Enhances efficiency via easy reuse of images.
Containerization is increasingly popular because containers are:
- Flexible: Even the most complex applications can be containerized.
- Lightweight: Containers leverage and share the host kernel.
- Interchangeable: You can deploy updates and upgrades on-the-fly.
- Portable: You can build locally, deploy to the cloud, and run anywhere.
- Scalable: You can increase and automatically distribute container replicas.
- Stackable: You can stack services vertically and on-the-fly.
Docker containers are built on top of Docker Engine. Each container operates on common Linux kernel of host machine.
- All needs for our App are defined in single tiny text file Dockerfile
- A sample of Dockerfile – the following few lines construct the whole environment which is production ready:
FROM ubuntu:16:04 RUN apt-get install -y redis-server EXPOSE 5379 ENTRYPOINT ["/usr/bin/redis-server"]
- Containers contain everything our app needs:
- File system
- Containers use the following items from the host:
Please find below video explaining the above concept.