Docker, a tool that packages software into containers that run reliably in any environment.

What is a Container ? and why you need one?

imagine you built an app with cobalt that runs on some weird falvor of linux, you want to share this app with you friend but he has a entirely different system. problem is how do we replicate the environment our software needs on any machine.

one way to pack and app is using virtual machines where the hardware simulated then installed required os and dependencies. this allows us to run multiple apps on the same infrastructure. btw this is bulky and slow due to high usage of resources.

DOCKER is a very similar VM with one key difference, instead of virtualizing hardware container only virtualize the OS (all apps and containers run by single kernel) this makes almost everything fast.


Docker Components

img

  • Dockerfile: A text document that contains instructions on how to build a Docker image.
  • Docker Image: A read-only template that contains the software and its dependencies.
  • Docker Container: A running instance of a Docker image.

Building a Docker Image

  • Start with a base image (e.g., Ubuntu).
  • Use commands like RUN to install dependencies and CMD to set the default command.
  • Build the image using the docker build command.

Running a Docker Container

img

  • Use the docker run command to create a container from an image.
docker run myapp
  • Containers can be run on any machine with Docker installed.

Additional points

  • Docker images are immutable, meaning they cannot be changed once they are created.
  • Docker containers can be easily scaled up or down.
  • Docker is a great tool for deploying and managing applications.