Docker

Harshitha G MHarshitha G M
2 min read

๐Ÿณ What is Docker?

Docker is a tool that helps you package your application and all its dependencies into a single unit called a container.
This container runs exactly the same on any machine โ€” laptop, server, or cloud โ€” solving the โ€œbut it worked on my system!โ€ problem.


๐Ÿงฑ Think of it like this:

  • ๐Ÿง Your application is like a cake.

  • ๐Ÿซ It needs ingredients (Python, Java, Node, libraries, etc.)

  • ๐Ÿฅก Docker puts everything needed (cake + ingredients) into a container box.

  • ๐Ÿ“ฆ You can now run this container anywhere, and it will work the same.


๐Ÿงฐ Why Docker is Useful:

  • โœ… Ensures consistency across environments (dev, test, prod)

  • โšก Fast setup โ€” no need to install dependencies manually

  • ๐Ÿ“ฆ Lightweight compared to virtual machines

  • ๐Ÿš€ Great for DevOps: works well with CI/CD tools like Jenkins, GitHub Actions, etc.


๐Ÿ“‚ Key Concepts:

TermMeaning
ImageA blueprint (like a recipe) of a container
ContainerA running instance of an image
DockerfileA script with steps to build an image
Docker HubOnline registry of pre-built images (like GitHub for Docker)

โš™๏ธ Basic Docker Commands:

docker --version  # Check Docker installed
docker pull nginx             # Download image from Docker Hub
docker run nginx              # Run container from image
docker ps                     # List running containers
docker stop <container_id>    # Stop a container
docker build -t myapp . 
# # Use official Java image
FROM openjdk:17
COPY . /app
WORKDIR /app
RUN javac MyApp.java
CMD ["java", "MyApp"]

Then run:
docker build -t my-java-app .
docker run my-java-app
0
Subscribe to my newsletter

Read articles from Harshitha G M directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Harshitha G M
Harshitha G M