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

    • 分布式
  • 编程框架工具

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

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

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

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

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

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

jorgen

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

    • 分布式
  • 编程框架工具

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

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

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

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

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

    • 通信协议
    • 安全
    • 云平台
收藏
  • 关于我
  • 终身学习
  • 关于时间的感悟
  • 分类
  • 标签
  • 归档
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

  • 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
上次更新: 2025/03/09, 15:45:50
Docker搭建

Docker搭建→

最近更新
01
STM32入门
03-09
02
ADB调试
03-09
03
微信小程序学习记录
02-09
更多文章>
Theme by Vdoing | Copyright © 2019-2025 Jorgen | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式