DEV Community

Jayesh Nalawade
Jayesh Nalawade

Posted on • Originally published at jayeshdevops.hashnode.dev

Docker Basics

Docker Basics: An Introduction to Containers

Docker is a powerful platform that allows developers to package, ship, and run applications in isolated environments called containers. Containers bundle all the necessary dependencies, configurations, and application code, making it easy to run applications consistently across different systems. Here’s an overview to get started with Docker.

What is Docker?

Docker enables containerization, which allows applications to run consistently across various environments. Unlike virtual machines, Docker containers are lightweight and share the host OS kernel, leading to faster startup times and reduced resource usage.

Key Concepts

  • Images: Templates used to create containers. An image is like a blueprint that includes your application code and dependencies.
  • Containers: Running instances of Docker images. A container is a lightweight, portable encapsulation of an environment for running applications.
  • Dockerfile: A text file with instructions for building a Docker image, specifying commands for setting up the environment, installing dependencies, and configuring the app.
  • Docker Hub: A public repository where Docker images are stored and shared.

Why Use Docker?

Docker offers several key benefits:

  • Consistency: Ensures applications run the same way across different environments.
  • Portability: Docker containers can be run on any system that supports Docker.
  • Efficiency: Containers use less memory and resources than virtual machines by sharing the host OS kernel.
  • Scalability: Applications can be easily scaled by deploying multiple containers.

Basic Docker Commands

Here are some essential Docker commands to get you started:


bash
# Check Docker version
docker --version

# Pull an image from Docker Hub
docker pull <image_name>

# List all Docker images
docker images

# Run a container from an image
docker run <image_name>

# Run a container and directly access bash
docker run -it <image_name> /bin/bash

# Access bash of an existing container
docker exec -it <container_id> /bin/bash

# List all running containers
docker ps

# Stop a running container
docker stop <container_id>

# Remove a container
docker rm <container_id>

# Remove an image
docker rmi <image_name>
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
rohit540073640t profile image
Rohit

Hii I need help in a dockerfile build for angular project