What is Docker?

What is Docker?

Docker is a platform designed to help developers build, share, and run modern applications.

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

  1. docker run: creates a container from an image

  2. docker pull: pull images from the docker repository

  3. docker start: starts one or more stopped container

  4. docker stop: stops a running container

  5. docker images: lists all the locally stored docker images

  6. docker ps: lists the running containers

  7. docker ps -a: show all the running and exited containers

Debug Commands

  1. docker logs: fetch logs of a container

  2. docker 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.

Did you find this article valuable?

Support Abhishek K by becoming a sponsor. Any amount is appreciated!