首页 > 其他分享 >Docker 入门文档阅读笔记

Docker 入门文档阅读笔记

时间:2024-08-20 11:26:09浏览次数:15  
标签:container 入门 image your 文档 run Docker its

Docker 的架构

Docker 客户端服务器架构

图片来自 Docker 官网教程

Docker 采用 CS 架构, 可以通过 CLIAPI 与 Docker daemon 进行交互。

Docker Objects

Images (镜像)

An image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization.

You might create your own images or you might only use those created by others and published in a registry. To build your own image, you create a Dockerfile with a simple syntax for defining the steps needed to create the image and run it. Each instruction in a Dockerfile creates a layer in the image. When you change the Dockerfile and rebuild the image, only those layers which have changed are rebuilt. This is part of what makes images so lightweight, small, and fast, when compared to other virtualization technologies.

Container (容器)

A container is a runnable instance of an image. You can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state.

By default, a container is relatively well isolated from other containers and its host machine. You can control how isolated a container's network, storage, or other underlying subsystems are from other containers or from the host machine.

容器运行例子

运行如下命令:

docker run -i -t ubuntu /bin/bash

运行过程解析:

When you run this command, the following happens (assuming you are using the default registry configuration):

  1. If you don't have the ubuntu image locally, Docker pulls it from your configured registry, as though you had run docker pull ubuntu manually.

  2. Docker creates a new container, as though you had run a docker container create command manually.

  3. Docker allocates a read-write filesystem to the container, as its final layer(在最终层,创建可读写的文件系统). This allows a running container to create or modify files and directories in its local filesystem.

  4. Docker creates a network interface to connect the container to the default network, since you didn't specify any networking options. This includes assigning an IP address to the container. By default, containers can connect to external networks using the host machine's network connection.

  5. Docker starts the container and executes /bin/bash. Because the container is running interactively and attached to your terminal (due to the -i and -t flags), you can provide input using your keyboard while Docker logs the output to your terminal.

  6. When you run exit to terminate the /bin/bash command, the container stops but isn't removed. You can start it again or remove it.

docker run 的选项说明:

  • -i, --interactive:交互模式,Keep STDIN open even if not attached
  • -t, --tty:Allocate a pseudo-TTY
  • -a, --attach:Attach to STDIN, STDOUT or STDERR
  • -d, --detach:在后台运行容器并返回容器 ID

The underlying technology (基于的技术 namespaces )

Docker is written in the Go programming language and takes advantage of several features of the Linux kernel to deliver its functionality. Docker uses a technology called namespaces to provide the isolated workspace called the container. When you run a container, Docker creates a set of namespaces for that container.

These namespaces provide a layer of isolation. Each aspect of a container runs in a separate namespace and its access is limited to that namespace.

标签:container,入门,image,your,文档,run,Docker,its
From: https://www.cnblogs.com/hexff/p/18360753/docker_tutorial

相关文章

  • Docker概述
    DockerⅠ容器介绍1.什么是容器容器一词的英文是container,其实container还有集装箱的意思,集装箱绝对是商业史上了不起的一项发明,大大降低了海洋贸易运输成本。让我们来看看集装箱的好处:·集装箱之间相互隔离·长期反复使用·快速装载和卸载·规格标准,在港口和船上都可以......
  • 文档版本控制:顶级工具软件盘点
    国内外主流的10款文档版本管理软件对比:1.PingCode;2.Worktile;3.Bazaar;4.语雀;5.AdobeAcrobat;6.Seismic;7.GoogleDocs;8.QT9QMS;9.石墨文档;10.飞书文档。在处理文档的日常工作中,版本管理常常成为一大挑战。错误的版本覆盖、找不到历史记录或是协作混乱——这些问题你是否也经常遇......
  • Docker compose 部署前后端-----采用nginx代理,支持一个端口部署多个前端
    Dockercompose部署前后端-----采用nginx代理,支持一个端口部署多个前端1、Linux服务器安装最新版docker,确保有dockercompose命令2、创建docker工作区目录mkdirdocker-workspace3、进入docker工作区目录,创建前端nginx目录,创建后端xxx目录mkdirnginxxxx4、创建confi......
  • 正则表达式入门:Python ‘ re ‘ 模块详解
    正则表达式(RegularExpression,简称re)是一种强大而灵活的工具,广泛用于字符串匹配、替换和分割等操作,尤其在处理网页爬虫数据时非常有用。Python提供了"re" 模块来支持正则表达式的使用,本文将结合常见的用法和示例,带你快速入门。正则表达式的常用方法匹配字符串1.'sea......
  • 国产GD32单片机开发入门(一) GD32F103C8T6开发板电路原理图分析
    文章目录一.概要二.技术名词解释三.板子主要电子器件四.原理图电路分析1.原理图总览2.电源电路1)5V电路2)3.3V电路3.LED指示灯电路4.复位电路5.晶振电路1)高频晶振电路2)低频晶振电路6.调试下载电路1)调试电路(SWD接线方式)2)BOOT电路7.外围接口电路8.模块拓展接口9......
  • 在K8S中,Kubernetes与Docker有什么关系?
    Kubernetes和Docker都是现代云原生技术栈的重要组成部分,但它们各自解决的问题领域不同。下面详细介绍它们之间的关系以及区别:1.DockerDocker是一个流行的容器化平台,它允许开发者将应用程序及其依赖打包成一个轻量级、可移植的容器。这样做的好处包括:隔离性:每个容器都有自......
  • SQL中的索引知识点复习文档
    SQL中的索引知识点复习文档此文档是数据分析课程入门篇关于索引知识点的复习文档,本次课程目标是回顾索引的分类、特点及常用操作,此课程代码练习较少,主要为理论知识的快速复习复习时间:2024年8月18日文档总结:2024年8月18日学习时长:视频课程1小时+文档总结1小时课程环境......
  • Unsafe入门讲解
    概述作为一个8年多Javaer,曾无数次看到Unsafe这个类,但一直没有去翻过源码,此为背景。借助于IDEA查看JDK源码,却发现有两个Unsafe类:sun.misc.Unsafejdk.internal.misc.Unsafejdk.internal.misc.Unsafe和sun.misc.Unsafe作为JDK中的两个不同类,它们提供一些底层的、非标准化的功......
  • SpringBoot文档之Profiles的阅读笔记
    ReferenceCoreFeaturesProfiles类似Maven的Profile特性,限定配置项取值的生效场景。在代码中,对于使用注解@Component、@Configuration、@ConfigurationProperties标记的类,可以增加@Profile,限定前述类的生效场景。类似如下样例代码,当启动时指定Profile为production时生......
  • helm3培训文档
    helm介绍1.传统服务部署到k8s集群的流程拉取代码——>打包编译——>构建镜像——>准备一堆相关部署的yaml文件(如:deployment、service、ingress等)——>kubectlapply部署到k8s集群2.传统方式部署引发的问题1).随着引用的增多,需要维护大量的yaml文件2).不能根据一套yaml文件来......