💻
Software Development
Technical Knowledges
Technical Knowledges
  • Everything anyone should know
    • Fundamental
      • Life cycle of Dependency Injection
        • When to use?
          • Transient
          • Scoped
          • Singleton
      • OOP
        • Inheritance
          • More with override in C#
            • Why need to use "virtual" keyword when we can use "new" keyword
          • How to achieve multiple inheritance in C#
          • Note
        • Polymophism
        • Encapsulation
        • Abtraction
          • Not use "override" keyword in abstract method
          • Notes
      • Data representing
        • JSON
        • XML
        • Comparation
      • Middleware
      • Status Code
      • API Styles
        • SOAP
        • REST
          • Question
        • GraphQL
        • gRPC
        • WebSocket
        • Webhook
        • Comparation
          • SOAP vs REST
          • REST vs GraphQL
          • gRPC vs REST
          • HTTP vs WebSocket
      • SDK
    • Advanced
      • Memoize
      • N+1 issues
      • Concurrency
        • Thread
          • Race Condition
          • Thread Safety
          • Critical Sections
        • Deadlock
        • Semaphore
    • Comparison
      • Architecture
        • SOA vs Microservices
        • Strong Consistency vs Eventual Consistency
      • Data structures
        • Instance vs Object
        • Field vs Property
        • Properties vs Method
        • Class vs Struct
        • const vs readoly vs static
        • Value types and Reference types
        • i++ vs ++i
        • Prototypal Inheritance vs Class Inheritance
        • Abstraction vs Interface
        • Run-time vs Compile-time
        • Overloading vs Overriding
      • Front-end
        • SSR vs SPA
        • Axios vs Fetch
      • Databases
        • Different between Function() and Store Procedure()
      • Security
        • Encoding vs Encryption vs Tokenization
      • Message Broker
        • RabbitMQ vs Kafka
      • Devops
        • Kubernetes vs Docker Swarm
        • Docker Repository vs Docker Registry
      • Cloud
      • Computer Science
        • Recursion and Iteration
      • Technology
        • .NET Core vs .NET Framework
        • Cache vs Local Storage vs Session Storage vs Cookies
      • SDLC
        • TDD vs BDD
  • Design Pattern
    • Overview
    • Creational Design Patterns
      • Abstract Factory
        • Code Example
          • C#
          • Java
          • Python
      • Builder
        • Code Example
          • C#
          • Java
          • Python
      • Factory Method
        • Code Example
          • C#
          • Java
          • Python
      • Prototype
        • Code example
          • C#
          • Java
          • Python
      • Singleton
        • Code example
          • C#
            • Naïve Singleton
            • Thread-safe Singleton
          • Java
            • Naïve Singleton (single-threaded)
            • Naïve Singleton (multithreaded)
            • Thread-safe Singleton with lazy loading
          • Python
            • Naïve Singleton
            • Thread-safe Singleton
    • Structural Design Patterns
      • Adapter
        • Code example
          • C#
          • Java
          • Python
            • Conceptual Example (via inheritance)
            • Conceptual Example (via object composition)
      • Bridge
        • Code example
          • C#
          • Java
          • Python
      • Composite
        • Code example
          • C#
          • Java
          • Python
      • Decorator
        • Code example
          • C#
          • Java
          • Python
      • Facade
        • Code example
          • C#
          • Java
          • Python
      • Flyweight
        • Code example
          • C#
          • Java
          • Python
      • Proxy
        • Code example
          • C#
          • Java
          • Python
    • Behavior Design Patterns
      • Chain of Responsibility
        • Code example
          • C#
          • Java
          • Python
      • Command
        • C#
        • Java
        • Python
      • Interpreter
        • Code example
          • C#
      • Iterator
        • Code example
          • C#
          • Java
          • Python
      • Mediator
        • Code example
          • C#
          • Java
          • Python
      • Memento
        • Code example
          • C#
          • Java
          • Python
      • Observer
        • Code example
          • C#
          • Java
          • Python
      • State
        • Code example
          • C#
          • Java
          • Python
      • Strategy
        • Code example
          • C#
          • Java
          • Python
        • Different with using abstract class
      • Template Method
        • Code example
          • C#
          • Java
          • Python
      • Visitor
        • Code example
          • C#
          • Java
          • Python
    • Use cases
      • Real-life example
    • More
      • Circuit Breaker Pattern
      • Repository Pattern
      • Unit Of Work Pattern
    • Some design patterns contradictory
  • Architect
    • Clean Architecture
    • Layered (n-tier) Architecture
    • Microservices Architecture
    • Monolithic Architecture
    • Service-Oriented Architecture (SOA)
    • Domain-Driven Design (DDD)
    • Blackboard Architecture
    • Object-Oriented Architecture
  • Microservices Design Pattern
    • Saga Pattern
      • Example
    • Strangler Fig Pattern
    • API Gateway Pattern
    • Backends For Frontends (BFF) Pattern
    • Service Discovery Pattern
    • Circuit Breaker Pattern
    • Bulk Head Pattern
    • Retry Pattern
    • Sidecar Pattern
    • Event Driven Architecture Pattern
    • CQRS (Command and Query Responsibility Segregation)
      • Event Sourcing
      • Code example
        • Basic
        • CQRS + MediatR + EDA + RabbitMQ
      • The Good, the Bad, and the Ugly
    • Configuration Externalization Pattern
  • Design and development principles
    • SOLID aka Design Principles
    • Cohesion Principles
    • Coupling principle
    • Some fundamental principles
      • Separation of Concerns
      • Persistence Ignorance
      • DRY
      • KISS
  • Authentication and Authorization Standards
    • SAML
    • OAuth
    • OIDC
    • SCIM
    • SSO
    • Tools
      • Keycloak
    • More
      • JWT
      • Access Token & Refresh Token
  • .NET TECHNOLOGY
    • .NET MVC
      • HTML Helpers
        • Extension method for HTML Helpers
      • Filters
        • Order of Filters
    • Fundamental
      • Startup file
      • Query Data
        • Linq
          • Filtering
          • Sorting
          • Projecting
          • Quantifying
          • Flattening
          • Grouping
          • Joining
          • Aggregating
          • Deferred execution vs Immediate execution
        • OData
          • Filter Expression
      • ORM
        • Entity Framework
          • Eager Loading vs Lazy Loading vs Explicit Loading
          • How to improve our entity framework core query performance
        • Dapper
        • Why Dapper faster than Entity Framework
      • Identity Server
      • Fluent Validation
      • Minimal API
      • Generic
      • IoC
        • Castle Windsor
        • Autofac
        • Ninject
      • CLR
      • Refit
      • Task Schedule
        • Hangfire
        • Quartz
      • Some notice
    • Advanced
      • Multi Thread
        • Thread pool
        • Parallel
        • Comparation
        • Code comparation
      • Caching
        • IMemoryCache
      • MediatR
      • SignalR
      • API Gateway
        • Ocelot
      • gRPC
      • Multitenancy
      • Special C# technique
        • Generic
        • Extension Method
        • Delegate
        • Lambda Expression
        • Yield
      • Jetbrain tools
        • dotTrace
        • dotMemory
        • dotPeek
      • ABP Framework
        • Multi Layered
          • Domain Layer
            • Entities
            • Repository
            • Domain Services
          • Application Layer
            • Application Services
            • Data Transfer Objects
          • Data Access
            • Entity Framework Core Integration
            • MongoDB Integration
        • Microservice Architecture
        • DDD
          • Domain Layer
            • Entities & Aggregate Roots
            • Value Objects
            • Repositories
            • Domain Services
            • Specifications
          • Application Layer
            • Application Services
            • Data Transfer Objects
            • Unit of Work
    • Tutorial Coding
      • Custom and Using Middleware in .NET CORE
      • Connect Elastic Search and MongoDB
      • Implementing the Unit of Work Pattern in Clean Architecture with .NET Core
    • ServiceStack
    • POCO
  • System Design
    • Blueprint
    • Fundamental
      • Scale from zero to millions of users
        • Single server setup
        • Database
        • Load balancer
        • Database replication
        • Cache
        • Content delivery network (CDN)
        • Stateless web tier
        • Data centers
        • Message queue
        • Logging, metrics, automation
        • Database scaling
        • Millions of users and beyond
      • A framework for system design interviews
        • Step 1 - Understand the problem and establish design scope
        • Step 2 - Propose high-level design and get buy-in
        • Step 3 - Design deep dive
        • Step 4 - Wrap up
        • Summarize
      • Back-of-the-envelope estimation
      • Design a rate limiter
        • Step 1 - Understand the problem and establish design scope
        • Step 2 - Propose high-level design and get buy-in
          • Algorithms for rate limiting
            • Token bucket algorithm
            • Leaking bucket algorithm
            • Fixed window counter algorithm
            • Sliding window log algorithm
            • Sliding window counter algorithm
          • High-level architecture
        • Step 3 - Design deep dive
          • Rate limiting rules
          • Exceeding the rate limit
          • Detailed design
          • Rate limiter in a distributed environment
          • Performance optimization
          • Monitoring
        • Step 4 - Wrap up
      • Design consistent hashing
        • Consitent hashing
        • Two issues in the basic approach
        • Wrap up
      • Design key-value store
        • Understand the problem and establish the design scope
        • CAP theorem
        • System components
          • Data partition
          • Data replication
          • Consistency
          • Inconsistency resolution
          • Handling failures
          • System architecture diagram
          • Write path
          • Read path
      • Design a unique id generator in distributed systems
        • Step 1 - Understand the problem and establish design scope
        • Step 2 - Propose high-level design and get buy-in
          • Multi-master replication
          • UUID
          • Ticket Server
          • Twitter snowflake approach
        • Step 3 - Design deep dive
        • Step 4 - Wrap up
      • Design a url shortener
        • Step 1 - Understand the problem and establish design scope
        • Step 2 - Propose high-level design and get buy-in
        • Step 3 - Design deep dive
          • Data model
          • Hash function
          • URL shortening deep dive
          • URL redirecting deep dive
        • Step 4 - Wrap up
      • Design a web crawler
        • Step 1 - Understand the problem and establish design scope
        • Step 2 - Propose high-level design and get buy-in
        • Step 3 - Design deep dive
          • DFS vs BFS
          • URL frontier
          • HTML Downloader
          • Robustness
          • Extensibility
          • Detect and avoid problematic content
        • Step 4 - Wrap up
    • Use cases
      • Design Youtube
      • Design Social Media App
      • Design Typehead Suggestion
      • Design Taxi Booking System
      • Design Messaging App
  • DBMS
    • Fundamental
      • ACID
      • Order Of Execution of the SQL query
      • Transaction – Concurrency Control Techniques
        • Isolation level
      • Index
        • Clustered Index vs Non-clustered index
        • Index vs Unique index
      • Built-in functions
        • String Functions
          • ASCII
          • CHAR
          • CHARINDEX
          • CONCAT
          • CONCAT_WS
          • DATALENGTH
          • DIFFERENCE
          • FORMAT
          • LEFT
          • LEN
          • LOWER
          • LTRIM
          • NCHAR
          • PATINDEX
          • QUOTENAME
          • REPLACE
          • REPLICATE
          • REVERSE
          • RIGHT
          • RTRIM
          • SOUNDEX
          • SPACE
          • STR
          • STUFF
          • SUBSTRING
          • TRANSLATE
          • TRIM
          • UNICODE
          • UPPER
        • Numeric Functions
          • ABS
          • ACOS
          • ASIN
          • ATAN
          • ATN2
          • AVG
          • CEILING
          • COUNT
          • COS
          • DEGREES
          • EXP
          • FLOOR
          • LOG
          • LOG10
          • MAX
          • MIN
          • PI
          • POWER
          • RADIANS
          • ROUND
          • SIGN
          • SIN
          • SQRT
          • SQUARE
          • SUM
          • TAN
        • Date Functions
          • CURRENT_TIMESTAMP
          • DATEADD
          • DATEDIFF
          • DATEFROMPARTS
          • DATENAME
          • DATEPART
          • DAY
          • GETDATE
          • GETUTCDATE
          • ISDATE
          • MONTH
          • SYSDATETIME
          • YEAR
        • Advance Functions
          • CASE
          • CAST
          • COALESCE
          • CONVERT
          • CURRENT_USER
          • LEAD
          • LAG
          • IIF
          • ISNULL
          • ISNUMERIC
          • NULLIF
          • SESSION_USER
          • SESSIONPROPERTY
          • SYSTEM_USER
          • USER_NAME
      • SQL Best Practice
      • Execution Plan
      • Optimize query execution
    • Advanced
      • CTE
      • Window function
      • Performance Tuning
        • Query tuning
        • Interview ques
      • DB Sharding
      • Concurrency Control
        • Optimistic lock
        • Pessimistic lock
      • Compare DELETE VS TRUNCATE
    • Comparation
      • Oracle vs SQL Server vs Postgre vs Mysql
  • Javascript
    • ES6 Techniques
      • Hoisting
      • Destructing
      • Spread Operator
      • Rest Operator
    • Basic
      • Const vs Let vs Var
      • Debounce & Throttle
      • Callback()
    • 5 ways to define a function
  • Clean code
    • Page 2
  • Search Engine
    • Elastic Search
      • Interview question
      • Code Example
    • Solr
    • IBM Watson Discovery
    • Google Cloud Search
    • Coveo Relevance Cloud
  • Cloud Service
    • Overview
    • Azure
      • Certificate
        • AZ-900
          • Describe cloud concepts
            • What is Cloud Computing?
            • Benefits of using cloud services
              • High Availability and Scalability
              • High Elasticity
              • High Reliability and Predictability
              • High Security and Governance
              • High manageability
            • IaaS vs PaaS vs SaaS
            • Cloud Deployment Models
            • CAPEX vs OPEX
          • Describe Azure architecture and services
            • Describe the core architectural components of Azure
              • Learn sandbox
              • Azure physical infrastructure
              • Azure management infrastructure
              • Create an Azure resource
            • Describe Azure compute and networking services
              • Azure Virtual Machines
              • Create an Azure Virtual Machine
              • Azure Virtual Desktop
              • Azure Containers
              • Azure Function
              • Describe application hosting options
              • Configure network access
              • Describe Azure Virtual Networking
              • Azure Virtual Private Networks
              • Azure ExpressRoute
              • Azure DNS
            • Describe Azure storage services
              • Azure storage accounts
              • Azure storage redundancy
              • Azure storage services
              • Create a storage blob
              • Identify Azure data migration options
              • Identify Azure file movement options
            • Describe Azure identity, access, and security
              • Azure directory services
              • Azure authentication methods
              • Azure external identities
              • Azure conditional access
              • Azure role-based access control
              • Zero trust model
              • Defense-in-depth
              • Microsoft Defender for Cloud
          • Describe Azure management and governance
            • Describe cost management in Azure
              • Factors that can affect costs in Azure
              • Compare the Pricing and Total Cost of Ownership calculators
              • Estimate workload costs by using the Pricing calculator
              • Compare workload costs using the TCO calculator
              • Azure Cost Management tool
            • Describe features and tools in Azure for governance and compliance
              • Azure Blueprints
              • Azure Policy
              • Purpose of resource locks
              • Configure a resource lock
              • Service Trust portal
            • Describe features and tools for managing and deploying Azure resources
              • Tools for interacting with Azure
              • Azure Arc
              • Azure Resource Manager and Azure ARM templates
            • Describe monitoring tools in Azure
              • Azure Advisor
              • Azure Service Health
              • Azure Monitor
        • SC-900
          • Describe the concepts of security, compliance, and identity
            • Describe security and compliance concepts
              • Shared responsibility model
              • Defense in depth
              • Zero Trust model
              • Encryption and hashing
              • Compliance concepts
            • Describe identity concepts
              • Authentication and authorization
              • Identity as the primary security perimeter
              • Role of the identity provider
              • Directory services and Active Directory
              • Federation
          • Describe the capabilities of Microsoft Azure Active Directory, part of Microsoft Entra
            • Describe the services and identity types of Azure AD
              • Azure Active Directory
              • Available Azure AD editions
              • Azure AD identity types
              • Types of external identities
              • Concept of hybrid identity
            • Describe the authentication capabilities of Azure AD
              • Authentication methods available in Azure AD
              • Multi-factor authentication (MFA) in Azure AD
              • Self-service password reset (SSPR) in Azure AD
              • Password protection and management capabilities of Azure AD
            • Describe the access management capabilities of Azure AD
              • Conditional Access in Azure AD
              • Benefits of Azure AD roles and role-based access control
            • Describe the identity protection and governance capabilities of Azure AD
              • Identity governance in Azure AD
              • Entitlement management and access reviews
              • Privileged identity Management
              • Azure Identity Protection
          • Describe the capabilities of Microsoft security solutions
            • Describe basic security capabilities in Azure
              • Azure DDoS protection
              • Azure Firewall
              • Web Application Firewall
              • Network segmentation in Azure
              • Azure Network Security groups
              • Azure Bastion and JIT Access
              • Describe ways Azure encrypts data
            • Describe security management capabilities of Azure
              • Cloud security posture management
              • Microsoft Defender for Cloud
              • Enhanced security of Microsoft Defender for Cloud
              • Microsoft cloud security benchmark and security baselines for Azure
            • Describe security capabilities of Microsoft Sentinel
              • SIEM and SOAR
              • How Microsoft Sentinel provides integrated threat management
              • Understand Sentinel costs
            • Describe threat protection with Microsoft 365 Defender
              • Microsoft 365 Defender services
              • Microsoft Defender for Office 365
              • Microsoft Defender for Endpoint
              • Microsoft Defender for Cloud Apps
              • Microsoft Defender for Identity
              • Microsoft 365 Defender portal
          • Describe the capabilities of Microsoft compliance solutions
            • Describe the Service Trust Portal and privacy at Microsoft
              • Service Trust Portal
              • Microsoft's privacy principles
              • Microsoft Priva
            • Describe the compliance management capabilities in Microsoft Purview
              • Microsoft Purview compliance portal
              • Compliance Manager
              • Describe use and benefits of compliance score
            • Describe information protection and data lifecycle management in Microsoft Purview
              • Know your data, protect your data, and govern your data
              • Data classification capabilities of the compliance portal
              • Sensitivity labels and policies
              • Data loss prevention
              • Retention policies and Retention labels
              • Records management
            • Describe insider risk capabilities in Microsoft Purview
              • Risk management
              • Communication compliance
              • Information barriers
            • Describe the eDiscovery and audit capabilities of Microsoft Purview
              • eDiscovery solutions in Microsoft Purview
              • Audit solutions in Microsoft Purview
            • Describe resource governance capabilities in Azure
              • Azure Policy
              • Azure Blueprints
              • Capabilities in the Microsoft Purview governance portal
        • DP-900
          • Core Concept
            • Explore core data concepts
              • Data formats
              • File storage
              • Databases
              • Transactional data processing
              • Analytical data processing
            • Explore data roles and services
              • Job roles in the world of data
              • Identify data services
          • Relational Data in Azure
            • Explore fundamental relational data concepts
              • Relational data
              • Normalization
              • SQL
              • Database objects
            • Explore relational database services in Azure
              • Azure SQL services and capabilities
              • Azure services for open-source databases
              • Exercise: Explore Azure relational database services
          • Non-relational data in Azure
            • Explore Azure Storage for non-relational data
              • Azure blob storage
              • Azure DataLake Storage Gen2
              • Azure Files
              • Azure Tables
              • Exercise: Explore Azure Storage
            • Explore fundamentals of Azure Cosmos DB
              • Azure Cosmos DB
              • Identify Azure Cosmos DB APIs
              • Exercise: Explore Azure Cosmos DB
          • Data analytics in Azure
            • Explore fundamentals of large-scale data warehousing
              • Data warehousing architecture
              • Data ingestion pipelines
              • Analytical data stores
              • Exercise: Explore data analytics in Azure with Azure Synapse Analytics
            • Explore fundamentals of real-time analytics
              • Understand batch and stream processing
              • Explore common elements of stream processing architecture
              • Azure Stream Analytics
              • Exercise: Explore Azure Stream Analytics Completed
              • Apache Spark on Microsoft Azure
              • Exercise: Explore Spark Streaming in Azure Synapse Analytics Completed
            • Explore fundamentals of data visualization
              • Power BI tools and workflow
              • Core concepts of data modeling
              • Considerations for data visualization
              • Exercise – Explore fundamentals of data visualization with Power BI Completed
        • AI-900
      • Azure Subscription
      • Azure App Service
      • Azure Dictionary B2C
      • Azure Front Door
      • Azure Traffic Manager
      • Azure Load Balancer
      • Azure KeyVault
      • API Management
      • Azure Logic Apps
      • Azure Metric and Logs
      • Azure Workbooks
      • Azure Messaging Services
      • Azure Service Fabric
      • Comparison
        • Durable Function vs Logic App
        • Storage queues vs Service Bus queues
        • Event Grid vs Service Bus
    • AWS
      • Certificate
        • CLF-C02
          • Cloud Concepts
            • Cloud Computing
            • The Deployment Models of the Cloud
            • The Five Characteristics of Cloud Computing
            • Six Advantages of Cloud Computing
            • Problems solved by the Cloud
            • Types of Cloud Computing
            • Pricing of the Cloud
            • AWS Global Infrastructure
              • AWS Regions
              • AWS Availability Zones
              • AWS Points of Presence (Edge Locations)
            • Tour of the AWS Console
            • Shared Responsibility Model diagram
          • Security & Compliance
            • AWS Shared Responsibility Model
            • DDOS
            • Network Firewall
            • Penetration Testing on AWS Cloud
            • Encryption
            • AWS Certificate Manager (ACM)
            • AWS Secrets Manager
            • AWS Artifact (not really a service)
            • Amazon GuardDuty
            • Amazon Inspector
            • AWS Config
            • AWS Macie
            • AWS Security Hub
            • Amazon Detective
            • AWS Abuse
            • Root user privileges
            • IAM Access Analyzer
            • Summary
            • Advanced Identity
              • STS
              • Cognito
              • Directory Services
              • IAM Identity Center
              • Summary
          • Cloud Technology & Services
            • IAM
              • IAM: Users & Groups
              • IAM: Permissions
              • IAM Policies inheritance
              • IAM Policies Structure
              • IAM – Password Policy
              • Multi-Factor Authentication - MFA
              • How can users access AWS?
                • AWS CLI
                • AWS SDK
              • IAM Roles for Services
              • IAM Security Tools
              • IAM Guidelines & Best Practices
              • Shared Responsibility Model for IAM
              • Summary
            • EC2
              • Overview
              • EC2 Instance Types
                • Overview
                • General Purpose
                • Compute Optimized
                • Memory Optimized
                • Storage Optimized
                • Example
              • Security Groups
              • SSH in EC2
              • EC2 Instance Purchasing Options
                • On-Demand Instances
                • Reserved Instances
                • Savings Plans
                • Spot Instances
                • Dedicated Hosts
                • Dedicated Instances
                • Capacity Reservations
                • Summary
              • EC2 Instance Storage
                • EBS
                • EBS Snapshot
                • AMI
                • EC2 Image Builder
                • EC2 Instance Store
                • EFS
                • Shared Responsibility Model for EC2 Storage
                • Amazon FSx
                • Summary
            • ELB & ASG
              • High Availability, Scalability, Elasticity
              • ELB
              • ASG
              • Summary
            • Amazon S3
              • Overview
              • Security
              • Techniques
              • Shared Responsibility Model for S3
              • AWS Snow Family
              • Summary
            • Database & Analytics
              • Overview
              • RDS & Aurora
              • Amazon ElastiCache
              • DynamoDB
              • Redshift
              • EMR
              • Amazon Athena
              • Amazon QuickSight
              • DocumentDB
              • Amazon Neptune
              • Amazon QLDB
              • Amazon Managed Blockchain
              • AWS Glue
              • DMS – Database Migration Service
              • Summary
            • Other Compute Service
              • Docker
              • ECS
              • Fargate
              • ECR
              • AWS Lamda
              • Amazon API Gateway
              • AWS Batch
              • Amazon Lightsail
              • Summary
                • Other Compute - Summary
                • Lambda Summary
            • Deploying and Managing Infrastructure
              • CloudFormation
              • CDK
              • Elastic Beanstalk
              • AWS CodeDeploy
              • AWS CodeCommit
              • AWS CodePipeline
              • AWS CodeArtifact
              • AWS CodeStar
              • AWS Cloud9
              • SSM
              • AWS OpsWorks
              • Summary
            • Global Infrastructure
              • Overview
              • Route 53
              • CloudFront
              • AWS Global Accelerator
              • AWS Outposts
              • AWS WaveLength
              • AWS Local Zones
              • Global Applications Architecture
              • Summary
            • Cloud Integration
              • Overview
              • SQS
              • Kinesis
              • SNS
              • MQ
              • Summary
            • Cloud Monitoring
              • CloudWatch
              • EventBridge
              • CloudTrail
              • X-Ray
              • CodeGuru
              • Health Dashboard
              • Summary
            • VPC
              • Overview
              • IP Addresses in AWS
              • VPC Diagram
              • Core networking
              • VPC Flow Logs
              • VPC Peering
              • VPC Endpoints
              • AWS PrivateLink (VPC Endpoint Services)
              • Site to Site VPN & Direct Connect
              • AWS Client VPN
              • Transit Gateway
              • Summary
            • Machine Learning
              • Rekognition
              • Transcribe
              • Polly
              • Translate
              • Lex & Connect
              • Comprehend
              • SageMaker
              • Forecast
              • Kendra
              • Personalize
              • Textract
              • Summary
            • Other Services
              • WorkSpaces
              • AppStream 2.0
              • IoT Core
              • Elastic Transcoder
              • AppSync
              • Amplify
              • Device Farm
              • Backup
              • Disaster Recovery Strategies
              • AWS Elastic Disaster Recovery (DRS)
              • DataSync
              • Application Discovery Service
              • Application Migration Service (MGN)
              • Migration Evaluator
              • Migration Hub
              • FIS
              • Step Functions
              • Ground Station
              • Pinpoint
          • Account Management, Billing & Support
            • Organizations
            • SCP
            • Control Tower
            • RAM
            • Service Catalog
            • Savings Plan
            • AWS Compute Optimizer
            • Billing and Costing Tools
            • Pricing Calculator
            • Tracking costs in cloud
              • Cost Explorer
            • Monitoring costs in the could
            • AWS Cost Anomaly Detection
            • AWS Service Quotas
            • Trusted Advisor
            • Support Plans
            • Summary
              • Account Best Practices
              • Billing and CostingTools
          • AWS Architecting & Ecosystem
            • General Guiding Principles
            • Well Architected Framework
              • Operational Excellence
              • Security
              • Reliability
              • Performance Efficiency
              • Cost Optimization
              • Sustainability
            • AWS CAF
            • AWS Right Sizing
            • AWS Ecosystem
      • Comparison
        • Region, Availability Zone and Edge Location in AWS
        • EBS vs EFS
    • GCP
    • OCI
    • Object Storage Server
      • MinIO
    • Comparison
      • Azure Active Directory B2C vs AWS Cognito
  • Front End
    • Basic
      • HTML
        • <ul> vs <ol>
        • <table>
      • CSS
        • Padding
        • Box Model
        • Outline
        • Text
        • Display
        • Position
        • z-index
        • Overflow
        • Float
        • Inline vs Inline-block
        • CSS Combinators
        • CSS [attribute] Selector
        • Website Layout
        • Unit
        • CSS The !important Rule
        • Flexbox
        • Comparation
          • div.classname vs div .classname
          • .classname vs .clasname #id vs .classname#id
      • JQuery
        • Syntax
        • Document
      • AJAX
    • Modern Framework
      • React
        • HOC
        • State Management
          • Redux
            • Selector
            • Middleware
              • Saga
              • Thunk
          • MobX
        • Hooks
        • Life Cycle
          • React Lifecycle Methods
          • React Lifecycle Hooks
          • Comparation
        • Signals
      • Angular
        • Directives
          • Component Directives
          • Attribute Directives
            • Built-in
            • Building an Attribute Directive
          • Structural Directives
            • Built-in
            • Custom
        • Binding
        • Components
        • Routing
      • Vue
    • Compile & Module
      • Webpack
      • Babel
    • TypeScript
      • Cheat sheet
    • Blazor
      • WebAssembly
    • UI Library
      • Formik
      • Material UI
      • Tailwind CSS
    • Security
      • Top 7 Common Frontend Security Attacks
    • Some notices
  • Microservices
    • Service Mesh
    • Service Registry
    • Service Discovery
    • Composition
    • Orchestration
    • Transformation
    • Dapr
  • Network
    • Protocols
      • Overview
      • HTTP
      • MQTT
      • AMQP
      • FTP
      • TCP
      • UDP
      • ICMP
    • OSI Model
  • Cache
    • Redis
      • What data should and should not be cached
      • Use cache in
      • Demo in .NET
    • Hazelcast
    • Memcached
  • Message Broker
    • RabbitMQ
      • Demo in .NET
      • Interview Ques
      • Use case
    • Kafka
      • Top 5 Kafka Use Case
    • ActiveMQ
    • Masstransit
  • Bash Script
    • Linux file system
    • Cheat sheet
    • 18 Most-used Linux Commands
    • Interview Question
  • Devops
    • Overview
      • What is ?
      • IaC
      • SAFe
      • Progressive Delivery
        • Blue Green Deployments
        • Canary Deployments
        • A/B Test
      • Platform Engineering
    • Azure Pipeline
    • Docker
      • What is ?
      • Docker Engine
        • Image
        • Docker file
          • Some commands
        • Container
        • Network
        • Volume
          • Additional infomation
      • Docker CLI
      • Docker Compose
        • Additional
      • Docker Security
        • Best Practice
        • Additional Information
      • Docker Swarm
      • Storing
        • Docker Registry
        • Docker Hub
      • Summarize
    • Kubernetes
      • What is ?
        • Additional
      • Kubernetes Pod
      • Replication Controllers
      • ReplicaSets and DaemonSets
        • Additional
      • Kubernetes Services
      • Deployment
        • Additional
      • Volume
      • PersistentVolumes
        • Additional
      • Configuration
        • Additional
      • StatefulSets
        • Additional
      • Downward API
      • Kubernetes internals architecture
      • Pod internal
      • ServiceAccount and Role Based Access Control
      • Network
        • Additional
      • Managing and calculating resources used for Pods
      • Automatic scaling Pods and clusters
      • Advanced scheduling
        • Taints and tolerations
        • Node affinity and Pod affinity
        • Additional
      • Adding custom resource to Kubernetes
    • Openshift
    • IaC
      • Terraform
        • Definition
        • Why chose Terraform?
        • IAC with Terraform
          • Terraform Workflow
            • Terraform Init
            • Terraform Plan
            • Terraform Apply
            • Terraform Destroy
          • Terraform Syntax
        • Terraform Architecture
          • Variable in terraform
          • Variable Type Contraint
          • Terraform Output
          • Terraform Provisioners
        • Terraform State
          • The concept
          • Local and Remote State Storage
          • Persisting Terraform State in AWS S3
          • Hand on
        • Terraform Modules
          • Accessing and Using Terraform Modules
          • Interating with Terraform Module Inputs and Outputs
          • Hand on
        • Built-in Functions and Dynamic Blocks
          • Built-in Function
          • Terraform Type Constraints (Collection & Structural)
          • Terraform Dynamic Block
          • Hand on
        • Terraform CLI
          • Terraform CLI: fmt, taint & import
          • Hand on
            • Practicing Terraform CLI commands(fmt, taint, import)
            • Using Terraform CLI Commands (workspace and state) to Manipulate a Terraform deployment
      • Ansible
    • Jenkin
    • GitOps
      • What is ?
      • Argo CD
    • Monitoring
      • Prometheus and Grafana
      • New Relic
  • Web Server
    • Apache
    • Nginx
    • IIS
  • Security
    • How to prevent crawl data
    • SQL Injection
    • OWASP
      • Web Application Security Risks
        • Broken Access Control
        • Cryptographic Failures
        • Injection
        • Insecure Design
        • Security Misconfiguration
        • Vulnerable and Outdated Components
        • Identification and Authentication Failures
        • Software and Data Integrity Failures
        • Security Logging and Monitoring Failures
        • Server-Side Request Forgery
      • API Security Risks
        • Broken Object Level Authorization
        • Broken Authentication
        • Broken Object Property Level Authorization
        • Unrestricted Resource Consumption
        • Broken Function Level Authorization
        • Unrestricted Access to Sensitive Business Flows
        • Server Side Request Forgery
        • Security Misconfiguration
        • Improper Inventory Management
        • Unsafe Consumption of APIs
    • Security headers
      • HTTP Strict Transport Security (HSTS)
      • Content Security Policy (CSP)
      • Cross Site Scripting Protection (X-XSS-Protection)
      • X-Frame-Options
      • X-Content-Type-Options
      • X-Permitted-Cross-Domain-Policies
      • Public Key Pinning (PKP)
        • What is HTTP Public Key Pinning and Why It’s Not Good to Practice
      • Expect-CT
        • The end of Expect-CT
      • Referer-Policy
      • Pragma
      • Cache-Control
        • Difference between Pragma and Cache-Control headers
      • Same-origin policy
      • Cross-origin resource sharing (CORS)
  • Data Change Capture (CDC)
    • Debezium
  • Software Development Life Cycle (SDLF)
    • Waterfall
    • V Model
    • Agile
      • Methods
        • Xtreme Programming
          • TDD
          • BDD
        • Scrum
        • Kanban
      • Question
  • Secure Software Development Framework (SSDF)
    • Page 1
  • Source Control
    • Git
    • SVN
    • TFS
  • Integration Systems
    • Stripe
    • Salesforce
    • TaxJar
    • Zendesk
  • Enterprise Service Bus (ESB)
    • Mulesoft
  • Data
    • 5 type of analytics
  • SOFTWARE QUALITY STANDARDS – ISO 5055
    • Standard
    • All about ISO 5055
  • Interview Question
    • Overview
      • Roadmap To Clearing Technical Interview
    • Technical
      • DSA
      • System Design
      • C#
      • React
    • Behavior
    • Question back to the interviewer
  • Roadmap
    • .NET
    • Java
  • English
    • Phát âm ed
    • Many vs much
    • Most vs most of vs almost vs the most
    • Quy tắc thêm s,es vào danh từ và cách phát âm s,es chuẩn xác nhất
  • Those will be seen later
    • Note
    • Interview
  • Programming Language
    • Python
      • Data structure
        • Set
    • Javascript
      • Data Structure
        • Map
    • C#
      • Data Structure
        • Value type & Reference type
        • Using statement
        • HashSet
        • Dictionary
        • Priority Queue
      • Fact
        • Understand about IEnumerable vs. IQueryable vs. ICollection vs. IList
        • 5 things you should know about enums in C#
    • Java
Powered by GitBook
On this page
  • What is Docker Image?
  • A little more about the Docker registry
  • Operation and storage mechanism of images
  • Images and containers
  • Image size is always small
  • Pulling images
  • Image registries
  • Official and unofficial repos
  • Name and tag in images
  • Image uses multiple tags
  • Search for images from Docker Hub
  • Images and layers
  • Commit from the original image
  • Create new image
  • Manage local images
  • Tag image
  • Download image
  • Upload local images to Docker Hub
  • Delete images
  • Export and Import images
  • Export images
  • Import images
  • Build automatically with Dockerfile
  • What is Dockerfile?
  • Build image from Dockerfile
  1. Devops
  2. Docker
  3. Docker Engine

Image

PreviousDocker EngineNextDocker file

Last updated 11 months ago

What is Docker Image?

Docker image is a fundamental element and an important component in Docker. Docker image can be understood as a record created by an individual or organization. If anyone has ever worked with VMs, they can understand that Docker images are similar to a snapshoot. But thanks to Docker technology, Docker images have special storage and management mechanisms to help optimize the system.

So where does the docker image come from? Docker image pulled from Docker registry. In addition, Docker images can also be created by users at different times.

A little more about the Docker registry

Docker registries are services that make repositories accessible to pull commands in Docker. Docker registry is responsible for distributing images between users quickly and extremely conveniently. The Docker organization itself also creates a free public Docker registry called Docker hub. On Docker hub today, there are many images that have been authenticated by large organizations and have been uploaded by users. You can search for the image you need on

You can also use CLI docker search ubuntu

Docker images are created by organizations or users in two ways:

  1. Commit from the original image.

  2. Build automatically with Dockerfile.

Operation and storage mechanism of images

Container storage using Union Filesystems (UFS) technology. This is a file system service developed for Linux to allow different file systems to be stacked (also called overlaid) to create an assembly or union of different files thereby creating a file system. single unified representation of the asset. Each change is recorded on a new layer and layered on top, above all other layers before it.

To put it more simply, those who have worked with Photoshop are familiar with the concept of Layers. When we want to lose an animal in a photo, we just need to add a new black layer over the original photo layer. The end user will receive a single merged avatar image that has lost the image of the animal that needs to be deleted in the image. On the manager's side, the change is made entirely on a different layer than the original photo layer.

This is essentially UFS in action, and it's one of the main reasons filesystems are so efficient at storage. Each layer includes only what is new and nothing is copied from a previous layer. There will be many read-only layers arranged below. There is a read/write layer on top that you can use to interact with the filesystem. When you read a file from the union filesystem, this file will be found and read from the highest layer. It will be down to the next layers until found.

You will not be able to make changes to the original image. If you want to commit your changes you must place another layer on top of the union filesystem, which is equivalent to committing and creating a new image. This is called the copy-on-write mechanism.

Command show most recent changes docker container diff ubuntu

Command to view all layers docker history ubuntu

Images are like a stopped container, so images are considered build-timeand containers are considered run-time.

Images and containers

When a container creates and runs from an image, the two structures become dependent on each other and the image cannot be deleted until the last container using it is deleted. Trying to delete an image without stopping or deleting the container will result in an error.

Image size is always small

The purpose of a container is to run an application or a service. This means it only needs the application's code and the dependencies it needs, it doesn't need anything else. So the image always has low capacity because it removes all non-essential parts.

Image does not contain kernel – All containers running on a Docker host share access to that host's kernel.

A good example of how small images can be is that the official Alpine image is about 5.5MB, there are images that can be smaller. A more typical example is the ubuntu 18.04 docker image with a capacity of about 60MB. The images have clearly had most of the unnecessary parts removed.

Some windows images tend to be a lot larger than Linux images due to the way it works. The capacity of the windows image can be up to several gigabytes and pulling will take more time.

Pulling images

Local image storage is usually located /var/lib/docker/imagein Linux and C:\ProgramData\docker\windowsfilterWindows. The following command can be used to check if there are any images stored locally.

root@docker:~# docker images
REPOSITORY                  TAG       IMAGE ID       CREATED        SIZE

The process of getting the image to the docker server is called pulling. So if we want to have a new image of the docker server, we can use it docker pulland test it againdocker images

For example:

root@docker:~# docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
540db60ca938: Already exists
Digest: sha256:69e70a79f2d41ab5d637de98c1e0b055206ba40a8145e7bddb55ccc04e13cf8f
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest
root@docker:~# docker images
REPOSITORY                  TAG       IMAGE ID       CREATED        SIZE
alpine                      latest    6dbb9cc54074   2 weeks ago    5.61MB

We see that the newly pulled images are already on the docker server.

Image registries

Registry contains 1 or more image repositories, image repositories contain 1 or more images. As the following figure shows how the registry stores images.

Official and unofficial repos

Docker Hub has two concepts: official repositories and unofficial repositories.

Official repositories are where images are hosted and managed by Docker, Inc. These repositories will be labeled by docker as Docker Official Images.

Uncensored unofficial repositories may not be secure because they are not audited. However, not all unmoderated repositories are bad, it's just that you should be careful before using things from unofficial repositories. It's best to trust images with high downloads or images from famous repos.

Examples of some official repos:

nginx: https://hub.docker.com/_/nginx/
busybox: https://hub.docker.com/_/busybox/
redis: https://hub.docker.com/_/redis/
mongo: https://hub.docker.com/_/mongo/

Examples of some unofficial repos:

nigelpoulton/tu-demo — https://hub.docker.com/r/nigelpoulton/tu-demo/
nigelpoulton/pluralsight-docker-ci — https://hub.docker.com/r/nigelpoulton/pluralsight-docker-ci/

Name and tag in images

To pull an image from the official repo, we need to specify the name of the repo and its tag separated by a comma :. If we do not specify the tag, it will understand the default tag as latest.

docker image pull <repository>:<tag>

For example to add an image from the official repository:

root@docker:~# docker image pull redis
Using default tag: latest
latest: Pulling from library/redis
f7ec5a41d630: Already exists
a36224ca8bbd: Pull complete
7630ad34dcb2: Pull complete
c6d2a5632e6c: Pull complete
f1957981f3c1: Pull complete
42642d666cff: Pull complete
Digest: sha256:e10f55f92478715698a2cef97c2bbdc48df2a05081edd884938903aa60df6396
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest

or

root@docker:~# docker pull httpd:2.4
2.4: Pulling from library/httpd
f7ec5a41d630: Already exists
d1589b6d8645: Pull complete
83d3755a8d28: Pull complete
f8459b08e404: Pull complete
30fabbf5a067: Pull complete
Digest: sha256:a6e472ad921c93d9fc2cbe2ff07560b9a526c145c4e10faff3aeb28c48cce585
Status: Downloaded newer image for httpd:2.4
docker.io/library/httpd:2.4

To add an image from an unofficial repo is the same as the official repo, but we add the name of the Docker Hub user or the name of the organization first.

docker image pull nigelpoulton/tu-demo:v2

Image uses multiple tags

An image can have many tags, if you want to pull all images in a repository, use the additional option -a.

docker image pull -a mongo
root@docker:~# docker image ls | grep "mongo"
mongo                  4.2.6               3f3daf863757        10 months ago       388MB
mongo                  3-stretch           27d820d7098b        23 months ago       373MB
mongo                  3-jessie            b9406b8a16ec        2 years ago         368MB
mongo                  2                   1999482cb0a5        4 years ago         391MB
mongo                  2.6                 1999482cb0a5        4 years ago         391MB
mongo                  2.6.12              1999482cb0a5        4 years ago         391MB
mongo                  2.4                 2affaf1f84e0        4 years ago         342MB
mongo                  2.4.14              2affaf1f84e0        4 years ago         342MB
mongo                  2.2                 8558fe135d54        4 years ago         237MB
mongo                  2.2.7               8558fe135d54        4 years ago         237MB
mongo                  2.6.11              f36fb0070896        5 years ago         391MB
mongo                  2.6.10              54fb6f9984dd        5 years ago         393MB
mongo                  2.6.9               0eb5bcb2f408        5 years ago         392MB
mongo                  2.4.13              1bc8a1a8ad40        5 years ago         344MB
mongo                  2.6.8               f287f6ca320f        5 years ago         393MB
mongo                  2.6.7               0fa5e3f671a7        6 years ago         392MB
mongo                  2.4.12              ae5e97f89258        6 years ago         345MB
mongo                  2.8                 4af37f2deb97        6 years ago         225MB
mongo                  2.8.0               4af37f2deb97        6 years ago         225MB
mongo                  2.8.0-rc5           4af37f2deb97        6 years ago         225MB
mongo                  2.8.0-rc4           c732b27ee3d6        6 years ago         224MB
mongo                  2.6.6               7632cab977f9        6 years ago         392MB
mongo                  2.8.0-rc3           84a5935d697f        6 years ago         224MB
mongo                  2.8.0-rc0           afb23b2838b9        6 years ago         224MB
mongo                  2.6.5               6e2f39336075        6 years ago         392MB
mongo                  2.7                 1bc6f44f84be        6 years ago         217MB
mongo                  2.7.8               1bc6f44f84be        6 years ago         217MB
mongo                  2.7.7               e29d06d58a5e        6 years ago         237MB
mongo                  2.4.11              be2b25bde5f5        6 years ago         345MB
mongo                  2.6.4               d90d629f1e23        6 years ago         391MB
mongo                  2.7.6               18400f87db91        6 years ago         381MB
mongo                  2.4.10              9ee0bcea2cbf        6 years ago         345MB
mongo                  2.7.5               5f79484e67e9        6 years ago         379MB
mongo                  2.6.1               f4eb787e7fd8        6 years ago         748MB

Search for images from Docker Hub

The command docker searchallows us to search Docker Hub from the CLI. For example to find alpine images on Docker Hub

root@docker:~# docker search alpine
NAME                                   DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
alpine                                 A minimal Docker image based on Alpine Linux…   7380      [OK]
mhart/alpine-node                      Minimal Node.js built on Alpine Linux           483
anapsix/alpine-java                    Oracle Java 8 (and 7) with GLIBC 2.28 over A…   469                  [OK]
frolvlad/alpine-glibc                  Alpine Docker image with glibc (~12MB)          259                  [OK]
alpine/git                             A  simple git container running in alpine li…   175                  [OK]
yobasystems/alpine-mariadb             MariaDB running on Alpine Linux [docker] [am…   86                   [OK]
alpine/socat                           Run socat command in alpine container           68                   [OK]
kiasaki/alpine-postgres                PostgreSQL docker image based on Alpine Linux   44                   [OK]
davidcaste/alpine-tomcat               Apache Tomcat 7/8 using Oracle Java 7/8 with…   44                   [OK]
jfloff/alpine-python                   A small, more complete, Python Docker image …   41                   [OK]
byrnedo/alpine-curl                    Alpine linux with curl installed and set as …   34                   [OK]
hermsi/alpine-sshd                     Dockerize your OpenSSH-server with rsync and…   33                   [OK]
zenika/alpine-chrome                   Chrome running in headless mode in a tiny Al…   33                   [OK]
hermsi/alpine-fpm-php                  FPM-PHP 7.0 to 8.0, shipped along with tons …   25                   [OK]
etopian/alpine-php-wordpress           Alpine WordPress Nginx PHP-FPM WP-CLI           24                   [OK]
bashell/alpine-bash                    Alpine Linux with /bin/bash as a default she…   18                   [OK]
davidcaste/alpine-java-unlimited-jce   Oracle Java 8 (and 7) with GLIBC 2.21 over A…   13                   [OK]
roribio16/alpine-sqs                   Dockerized ElasticMQ server + web UI over Al…   12                   [OK]
spotify/alpine                         Alpine image with `bash` and `curl`.            11                   [OK]
cfmanteiga/alpine-bash-curl-jq         Docker Alpine image with Bash, curl and jq p…   6                    [OK]
hermsi/alpine-varnish                  Dockerize Varnish upon a lightweight alpine-…   3                    [OK]
ellerbrock/alpine-mysql-client         MySQL Client based on Alpine Linux              1                    [OK]
dwdraju/alpine-curl-jq                 Alpine Docker Image with curl, jq, bash         1                    [OK]
goodguykoi/alpine-curl-internal        simple alpine image with curl installed no C…   1                    [OK]
bushrangers/alpine-caddy               Alpine Linux Docker Container running Caddys…   1                    [OK]
  • Column NAME: indicates the name of the image

  • Column DESCRIPTION: brief description of images

  • Column OFFICIAL: indicates whether the image is official or unofficial

If you only want to find official images, use the following command to filter:

docker search alpine --filter "is-official=true"

Images and layers

Layer in images

Images Docker is a series of read-only layers connected together. Each layer includes 1 or more files.

In fact, when we pull an image, we will see the layers of that image:

root@docker:~# docker image pull ubuntu:latest
latest: Pulling from library/ubuntu
952132ac251a: Pull complete
82659f8f1b76: Pull complete
c19118ca682d: Pull complete
8296858250fe: Pull complete
24e0251a0e2c: Pull complete
Digest: sha256:f4691c96e6bbaa99d...28ae95a60369c506dd6e6f6ab
Status: Downloaded newer image for ubuntu:latest
docker.io/ubuntu:latest

Each line will end with Pull completea representation of a layer that has been pulled.

Another way to view an image's layers is to use docker image inspect:

root@docker:~# docker inspect ubuntu:latest
[
    {
        "Id": "sha256:bd3d4369ae.......fa2645f5699037d7d8c6b415a10",
        "RepoTags": [
            "ubuntu:latest"
            
        <Snip>

        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:c8a75145fc...894129005e461a43875a094b93412",
                "sha256:c6f2b330b6...7214ed6aac305dd03f70b95cdc610",
                "sha256:055757a193...3a9565d78962c7f368d5ac5984998",
                "sha256:4837348061...12695f548406ea77feb5074e195e3",
                "sha256:0cad5e07ba...4bae4cfc66b376265e16c32a0aae9"
            ]
        }
    }
]

Docker is used storage driverto take responsibility for stacking layers and presenting them as a unified whole. Examples of storagedrivers include: AUFS, overlay2, devicemapper, btrfsand zfs.

Share layers between images

Images can share layers with each other, which leads to space and performance efficiency. When pulling an image, the layer status is announced meaning Already existsthat layer already exists and the image will use that layer without needing to pull a new layer.

Multi-architecture images

Docker images can support multiple architectures, meaning an image can contain multiple variants for different architectures and sometimes for different operating systems.

When running an image that supports multi-architecture, docker will automatically choose an image variant that matches the operating system and architecture of the machine. Most images offer a variety of architectures.

This means that an image such as golang can have images for linux on x64, or different versions on ARM and more. This means that when you are on any platform or architecture and pull an image, docker will pull the exact image suitable for that platform or architecture.

To do this, the Registry API supports two structures:

  • manifest lists

  • manifests

The picture above shows that when we pull an image, we will rely on the CPU architecture of the docker server to choose the appropriate version. We don't need to specify whether we need a linux x64 or windows x64 version, just run the commands as usual and docker itself will process it to get an image that matches the architectural platform on which the docker server is running.

Delete images

When we no longer need images on our docker, we can use them docker image rmto delete images. When deleting an image, all its layers will be deleted. However, if a layer of an image is shared with many other images, that layer will not be deleted until all images referencing it are deleted.

root@docker:~# docker image rm httpd:2.4
Untagged: httpd:2.4
Untagged: httpd@sha256:a6e472ad921c93d9fc2cbe2ff07560b9a526c145c4e10faff3aeb28c48cce585
Deleted: sha256:0b932df43057fbcc4276ae50fc0efe2f446d1955066d5774e764ef1f77638511
Deleted: sha256:2a455380a6b6556b6c74970d3ed6ed7cdf129faf017b0df678cf90c661df7971
Deleted: sha256:cb1255155eeaa614a1c12714454886e6581b78bc5942d1edf1910f67b9b81ea2
Deleted: sha256:6e35a2713ae7c4b470f2e3e245c3f0f7808911d4086ecd32e1dc9b53c184a94a
Deleted: sha256:902d020d1a22522b22d02e2787652b9f4b306d619d742216eeee0af2d800cde2

To delete all images, use the following command:

docker image rm $(docker image ls -q) -f

Commit from the original image

Create new image

To create a new image save the new changes to that container. Docker commit alpine aline:v1.0

Use the key combination Ctrl P then Ctrl Q to exit the bash container while still keeping the container running.

Manage local images

List images docker images

Tag image

Basically when you make a commit without any additional options after it. The system will create a new image without the name and tag of that image. Therefore, it is necessary to perform additional docker tag commands. docker tag 5aa951fd5198 alpine:v1.0 Normally you should add the name and tag for the image in the commit command. Here is an example to further explain the image creation process.

Download image

For images that do not exist on the local machine. You can use the docker pull command to download versions of images to your computer in advance for use in cases where you need to travel without internet. docker pull nginx

Upload local images to Docker Hub

You can share personal images by uploading your images to Docker hub after you build an image. docker push daihv/hello_dockerfile:v1.0 This section will have a clearer example in section 3.2. Build image from Dockerfile

Delete images

With junk images you don't need, you can delete them. docker rmi demo:v1.0

You can delete all images with the following command (consider before doing) docker system prune -a

Export and Import images

Export images

Allows you to backup one or more images into a file that can be stored or sent. Often used to bring images to customers. docker save -o backup.tar.gz alpine:v1.0 busybox:latest

Import images

Allows you to restore previously backed up images. docker load -i backup.tar.gz

Build automatically with Dockerfile

What is Dockerfile?

Dockerfile is a text file containing instructions for building an image. The Docker image builder executes the Dockerfile from top to bottom, and instructions can configure or change anything about the image. Dockerfiles are the most common way to describe how to build images. Dockerfile can be understood as a shell script. which contains command lines, running the steps to create an image.

Build image from Dockerfile

In Dockerfile syntax it always starts with the FROM keyword.

FROM alpine:latest EXPOSE 8080 RUN ip add LABEL version="1.0" USER daihv ADD ./ebook1.txt /tmp WORKDIR /home/daihv/app ENV APP_HOME=/wildfly COPY ./ebook2.txt /tmp VOLUME /var/log ENTRYPOINT ["ls","-a"] CMD echo "oke oke"

In there:

  • FROM specifies which original image to execute from.

  • EXPOSE specifies the listening port.

  • RUN executes any command.

  • LABEL adds a descriptive label.

  • USER specifies the executing user.

  • ADD copies files from the host into the container which can also be a URL

  • WORKDIR indicates the default working directory.

  • ENV sets environment variables if any.

  • COPY is similar to ADD but cannot be used against URLs

  • VOLUME indicates the storage directory on the host.

  • ENTRYPOINT like CMD is used to run when creating a container, but ENTRYPOINT cannot be overwritten from the command line when starting a container.

  • CMD executes the default command when we initialize the container from the image, this default command can be overridden from the command line when initializing the container.

Step 1: Create a file named dockerfile touch dockerfile

Step 2: Write the steps to deploy an image nano dockerfile

Step 3: Execute build

docker build -t new_alpine:v1.0 -f dockerfile . The command uses the * -t * flag to give the image a new name. And use the -f flag to specify the build file in case there are many dockefiles in a directory.

Step 4: Upload new image to Docker hub You need to have a Docker Hub account and create a repository first.

Re-tag the built images to match the repository on Docker hub. docker tag new_alpine:v1.0 daihv/demo:v1.0

Login to your Docker hub account docker login --username=daihv

Upload to repository docker push daihv/demo:v1.0

Check back on Docker hub

As mentioned in previous sections, images are stored in centralized storage locations called image registries. This makes it easy to share and access. The popular and default used registry is .

Docker Hub
hub.docker.com