Docker

๐ณ 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:
Term | Meaning |
Image | A blueprint (like a recipe) of a container |
Container | A running instance of an image |
Dockerfile | A script with steps to build an image |
Docker Hub | Online 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
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
