What is Docker?
Docker is a platform designed to help developers build, share, and run modern applications.
Table of contents
Introduction to containers and docker
Docker
Docker is an open source containerization platform. Enables developers to package applications into containers. Containers existed already before. Docker made containers popular.
Container
A way to package applications with all the necessary dependencies and configuration. Portable standardized artifact for development, shipment and deployment. Makes development and deployment more efficient.
Docker is the most popular container technology, others are containerd, cri-o etc
Docker Image vs Docker Container
Docker Image | Docker Container |
The actual package (file) | Starts the application |
An artifact that can be moved around | Is a running environment defined in the image |
Not in "running" state | In "running" state |
Consists of several layers | Virtual file system |
Mostly Linux Base Image, application image on top | Port binding: talk to an application running inside the container |
You can't run a Linux container on a Windows host, but for that, there is Docker Desktop for Windows and Mac
Docker Architecture & its components - 1
Docker Architecture & its components - 2
Docker Architecture & its components - 3
Main Docker Commands
docker run:
creates a container from an imagedocker pull:
pull images from the docker repositorydocker start:
starts one or more stopped containerdocker stop:
stops a running containerdocker images:
lists all the locally stored docker imagesdocker ps:
lists the running containersdocker ps -a:
show all the running and exited containers
Debug Commands
docker logs:
fetch logs of a containerdocker exec -it:
creates a new bash session in the container
Ports in Docker
Multiple containers can run on your host machine
Problem: But your laptop has only certain ports available Conflict when the same port is on the host machine, so we need to map to a free port on the host machine:
port mapping -
docker run -p 8080:8080 {image}
Container Port = Port used in container
Host Port = Port on the host machine
Workflow with Docker
Conclusion
Thank you everyone for reading. I just explained the basics of Docker. I strongly encourage you all to read more related articles on Docker. I hope this article helped you.