Skip to content

akashdip2001/docker

Repository files navigation

Docker Notes for DevOps Engineering

Table of Contents

1. Introduction to Docker

2. Docker Command Line Interface (CLI)

3. Docker Custom Images

4. Docker Networking

5. Docker Volumes

6. Docker Compose


Docker Notes for DevOps Engineering


1. Introduction to Docker

  • Definition: Docker is a platform for developing, shipping, and running applications inside lightweight, portable containers.
  • Key Benefits:
    • Consistency across environments
    • Rapid application deployment
    • Resource efficiency compared to traditional VMs
  • Steps to Install:

    • Windows : Use Docker Desktop (CLI + GUI)
    • Linux: Use package managers like apt or yum
    • MacOS: Docker Desktop or brew install docker
  • Check Installation: Run docker --version.

    image Guide
    πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯

    Screenshot (654) Screenshot (656) Screenshot (658) Screenshot (657) πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯

    ========================>>> Its automaticly detect the WSL Linux

    Screenshot (665)

  • Image: A lightweight, standalone, and executable software package.
  • Container: An instance of an image running as an isolated process.
  • Commands:
    docker pull <image-name>
    docker run <image-name>

Screenshot (666)

  • A cloud-based repository to store and share Docker images.
  • Usage:
    • Find public images
    • Push custom images using docker push

2. Docker Command Line Interface (CLI)

  • Purpose: Manage images, containers, and Docker resources using the terminal.
  • Basic Commands:
    • docker ps – List running containers
    • docker images – List images
  • Key Commands:
    • docker pull <image> – Download an image
    • docker rmi <image> – Remove an image
  • Key Commands:
    • docker run <image> – Start a container
    • docker stop <container> – Stop a running container
    • docker logs <container> – View logs from a container
  1. Running Ubuntu img in Containers
  2. Multiple Containers
  3. Port Mapping

3. Docker Custom Images

  • Definition: A text file containing instructions to build a Docker image.
  • Sample Dockerfile:
    FROM node:14
    COPY . /app
    WORKDIR /app
    RUN npm install
    CMD ["node", "app.js"]
  • Command to Build:
    docker build -t <image-name> .
  • Steps to:
    • Create a Dockerfile
    • Use docker build and docker run
  • Map ports using -p flag:
    docker run -p 3000:3000 <image>
  • Authenticate: docker login
  • Push Image:
    docker tag <image> <username>/<repository>
    docker push <username>/<repository>

4. Docker Networking

  • Default mode. Containers share the host's networking but are isolated.
  • Command:
    docker network inspect bridge
  • Shares the host network namespace.
  • Useful for performance-critical apps.
  • Enables multi-host container communication.
  • Advanced networking modes for performance and integration.
  • Completely disables networking for the container.

5. Docker Volumes

  • Mount directories from the host into the container.
  • Command:
    docker run -v /host/path:/container/path <image>
  • Named volumes for persistent storage:
    docker volume create myvolume

6. Docker Compose

  • A tool to define and run multi-container Docker applications.
  • Sample docker-compose.yml:

    version: '3'
    services:
      app:
        image: node:14
        ports:
          - "3000:3000"
  • Commands:

    docker-compose up
    docker-compose down

Tables for Quick Reference

Command Description
docker pull <image> Download an image
docker run <image> Create and start a container
docker ps List running containers
docker stop <container> Stop a running container
docker volume create Create a named volume
Networking Mode Description
Bridge Default mode, isolated container networking
Host Shares host's network namespace
Overlay For multi-host communication

Releases

No releases published

Packages

No packages published