Jorgen's blog Jorgen's blog
首页
  • 平台架构
  • 混合式开发记录
  • 推送服务
  • 数据分析
  • 实时调度
  • 架构思想

    • 分布式
  • 编程框架工具

    • 编程语言
    • 框架
    • 开发工具
  • 数据存储与处理

    • 数据库
    • 大数据
  • 消息、缓存与搜索

    • 消息队列
    • 搜索与日志分析
  • 前端与跨端开发

    • 前端技术
    • Android
  • 系统与运维

    • 操作系统
    • 容器化与 DevOps
  • 物联网与安全

    • 通信协议
    • 安全
    • 云平台
newland
  • 关于我
  • 终身学习
  • 关于时间的感悟
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

jorgen

Love it, make mistakes, learn, keep grinding.
首页
  • 平台架构
  • 混合式开发记录
  • 推送服务
  • 数据分析
  • 实时调度
  • 架构思想

    • 分布式
  • 编程框架工具

    • 编程语言
    • 框架
    • 开发工具
  • 数据存储与处理

    • 数据库
    • 大数据
  • 消息、缓存与搜索

    • 消息队列
    • 搜索与日志分析
  • 前端与跨端开发

    • 前端技术
    • Android
  • 系统与运维

    • 操作系统
    • 容器化与 DevOps
  • 物联网与安全

    • 通信协议
    • 安全
    • 云平台
newland
  • 关于我
  • 终身学习
  • 关于时间的感悟
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • Docker

    • 简介
      • container advantage
      • What is container?
      • Difference between Docker Image and Docker Container?
      • Docker vs Virtual Machine
      • Installing Docker
      • Common Command
      • Debug docker
      • Docker compose
      • Docker file
      • docker registry
      • Deploy containered image
      • Docker Volumes
      • how to use it to persite docker data?
    • Docker搭建
    • docker-compose安装
    • Portainer
  • k8s

  • 基础设施即代码(IaC):自动化运维的革命
  • CI/CD:构建自动化部署流水线
  • GitOps:声明式基础设施管理的未来
  • GitOps:声明式基础设施管理的演进
  • IaC与CI/CD集成:实现基础设施与应用程序的一体化自动化
  • IaC安全与合规:构建可信赖的基础设施代码
  • IaC工具对决:Terraform、Ansible与CloudFormation的全面比较
  • IaC工具对比与选择:Terraform、Ansible、Pulumi等工具详解
  • 基础设施即代码-IaC-最佳实践指南
  • 基础设施即代码工具对比:从Terraform到Pulumi的选择指南
  • 基础设施即代码工具对比与实践指南
  • 持续集成与持续部署-CI/CD-DevOps的核心引擎
  • 持续集成与持续部署-CI/CD-DevOps自动化的核心引擎
  • 持续集成与持续部署-CI/CD-加速软件交付的引擎
  • 持续集成与持续部署-CI/CD-构建高效交付流水线
  • IaC最佳实践:构建可维护的基础设施代码
  • IaC状态管理-基础设施即代码的基石
  • IaC多环境管理-跨越开发到生产的无缝部署
  • 构建全方位可观测性体系-DevOps监控实践指南
  • DevSecOps-将安全融入DevOps的完整指南
  • DevOps文化转型-构建高效协作的团队文化
  • 混沌工程-在不确定性中构建弹性系统
  • DevOps中的测试策略-构建质量驱动的持续交付体系
  • DevOps中的性能工程-构建高效能应用的全流程优化
  • FinOps-将财务责任融入DevOps的云成本优化实践
  • DevOps中的可扩展性与弹性架构设计 - 构建适应未来的云原生系统
  • DevOps中的平台工程-构建赋能开发者的内部平台
  • DevOps中的AI革命:智能化运维与自动化的未来
  • DevOps中的数据管理-构建数据库即代码的完整指南
  • devops
  • Docker
Jorgen
2023-02-14
目录

简介

advantage

# container advantage

  1. easy to develop
  2. easy to deploy

# What is container?

  1. Layers of images:only different layers are downloaded
  2. Mostly Linux Base Image, small in size
  3. Application image on top

# Difference between Docker Image and Docker Container?

Docker Image

  1. the actual package
  2. artifact,that can be moved around
  3. not running

Docker Container

  1. actually start the application
  2. container environment is created
  3. running

# Docker vs Virtual Machine

Application — OS Kernel — Hardware

Docker

  1. Application layer, it uses host OS Kernel
  2. docker image’s size smaller than VM
  3. running speed faster

Virtual Machine

  1. Both Application And its own OS kernel.
  2. good Compatibility than Docker

# Installing Docker

  1. doc url (opens new window)
  2. pre-requirement
  3. docker-toolbox that brige enable OS to run docker

# Common Command

  1. docker pull [name]:[version] if no version, then will get the latest version.
  2. docket images : show list images you have pulled
  3. docker run [xxx]: to run an image ; -d daemon; -p bind host port to container port. —name:specify a name.
docker run -d -p6000:6379 —name redis redis
1
  1. docker ps : show you have running containers; -a: show history you have running.
  2. docker stop [containerId]:gracelly stop the running container.

# Debug docker

  1. docker log [containerId]/[container name]:show logs when docker running an images.
  2. docker exec -it(inside terminal) [containerId/containerName] /bin/bash:check running container’s running state
docker log redis
docker exec -it redis /biin/bash
1
2

docker run vs docker start

docker run: create a new container
docker start: restart a stopped container
1
2

# Docker compose

  1. specify the docker run command in yaml file.
  2. every config can map to the docker run command

# Docker file

Untitled

  1. start by basing it on another image
  2. optionally define environment variables(recommend)
  3. run — execute any linux command
  4. copy — execute command on the HOST machine
  5. CMD[”node” , “server.js”] — execute node server.js command
  • CMD = entrypoint command
  • docker file is blueprint of any docker image, that means any docker image is on the docker hub should be built on its own docker file.
  • when you adjust the Dockerfile, you MUST rebuild the Image
docker build -t name:tag
1

# docker registry

Untitled

author use A.W.S for example.

docker tag name:tage  xxx/cloudserver/name:tag  -- 重命名
docker push xxx/cloudserver/name:tag            -- 推送docker to docker repository     
1
2

# Deploy containered image

The Server needs to login to pull from PRIVETE repository;Login not needed for PUBLIC DockerHub.

# Docker Volumes

When do we need Docker Volumes?

Data is gone! When restarting or removing the container. The container has virtual file system which is mapping the host’s physical file system.

3 Volume Types

  1. Host Volume:you decide where on the host file system the reference is made.
docker run -v host file dir : container file dir
1
  1. Anonymous Volumes:for each container a folder is generated that gets mounted.
docker run -v /var/lib/mysql/data --> /var/lib/docker/volumes/random-hash/_data
1
  1. Named Volumes:you can reference the volume by name; (👍👍👍)
docker run -v name:/var/lib/mysql/data
1

# how to use it to persite docker data?

  1. config it on docker-compose.yaml
version:'3'
services: 
	mongodb:
  images: mongo
	ports:
		- 27017:27017
	volumes:
		- mongo-data:/data/db [mysql:var/lib/mysql / postgres: var/lib/postgresql/data]
  xxx-other config
volumes:
	mongo-data:
	driver: local
1
2
3
4
5
6
7
8
9
10
11
12
  1. Docker Volume Locations
    1. Windows:C:\ProgramData\docker\volumes
    2. Linux:/var/lib/docker/volumes
    3. Mac:/var/lib/docker/volumes
#Docker
上次更新: 2026/01/28, 13:30:02
Docker搭建

Docker搭建→

最近更新
01
LLM
01-30
02
intro
01-30
03
intro
01-30
更多文章>
Theme by Vdoing | Copyright © 2019-2026 Jorgen | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式