DEV Community

Sugash Srimari R
Sugash Srimari R

Posted on

DOCKER BASICS FOR BEGINNER

Introduction

In today's fast-paced development world, Docker has become an essential tool for developers. Whether you're building web applications, microservices, or AI-powered tools, Docker simplifies deployment and ensures consistency across environments. If you're new to Docker, this guide will help you get started with the basics!

   docker --version
Enter fullscreen mode Exit fullscreen mode

Run a test container:

   docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Key Docker Concepts

  1. Images: Blueprints for containers, stored in Docker Hub or locally.
  2. Containers: Running instances of images.
  3. Dockerfile: A script containing instructions to build an image.
  4. Volumes: Persistent storage for containers.
  5. Networks: Enable communication between containers.

Basic Docker Commands

  • List running containers:
  docker ps
Enter fullscreen mode Exit fullscreen mode
  • Start a container:
  docker run -d -p 8080:80 nginx
Enter fullscreen mode Exit fullscreen mode
  • Stop a container:
  docker stop <container_id>
Enter fullscreen mode Exit fullscreen mode
  • Remove a container:
  docker rm <container_id>
Enter fullscreen mode Exit fullscreen mode
  • Build an image from a Dockerfile:
  docker build -t myapp .
Enter fullscreen mode Exit fullscreen mode

Creating Your First Dockerized Application

  1. Create a Dockerfile:
   FROM node:18
   WORKDIR /app
   COPY . .
   RUN npm install
   CMD ["npm", "start"]
   EXPOSE 3000
Enter fullscreen mode Exit fullscreen mode
  1. Build and run your container:
   docker build -t mynodeapp .
   docker run -p 3000:3000 mynodeapp
Enter fullscreen mode Exit fullscreen mode

Conclusion

Docker is a game-changer for modern development. With just a few commands, you can containerize your applications, making them portable, scalable, and easy to deploy. Start experimenting with Docker today and streamline your development workflow!

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post →

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post