docker 基于容器创建本地web容器化镜像

一、docker 基于容器创建本地web容器化镜像

1、启动指定buysbox 镜像

docker run --name b1 -it busybox:latest

2、创建目录,并创建html

mkdir -p /data/html
vi index.html

内容自定义例如:<h1>welcome to busybox<h1>

3、新增窗口,创建镜像

docker commit -a "user<6666@qq.com>" -c 'CMD ["/bin/httpd","-f","-h","/data/html/"]' -p b1 rep/user:v3.0

命令解析:

[root@localhost ~]# docker commit --helpUsage:  docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]Create a new image from a container's changesOptions:-a, --author string    Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")-c, --change list      Apply Dockerfile instruction to the created image-m, --message string   Commit message-p, --pause            Pause container during commit (default true)

-a 是设置作者的名字和邮箱

-c 是指定 dockerfile 的配置。例如上面是执行CMD里面的命令。让他启动容器时候就运行

/bin/httpd -f -h /data/html/  ,这样,启动容器化后就可以访问到html index.html 页面

-p 是新建容器,暂定容器

b1 是启动的容器化的命名

查看镜像

[root@localhost ~]# docker image ls
REPOSITORY               TAG             IMAGE ID       CREATED          SIZE
rep/user                 v3.0            ac68fbf602d6   11 seconds ago   1.24MB
rep/tag                  v3.0            d9b9295a2e80   19 minutes ago   1.24MB
rep/tag                  v2.0            89014fda351b   51 minutes ago   1.24MB
res/wuhuhuan             v1.1.1          89014fda351b   51 minutes ago   1.24MB
busybox                  latest          16ea53ea7c65   2 years ago      1.24MB
quay.io/coreos/flannel   v0.14.0-arm64   85fc911ceba5   2 years ago      67.2MB
nginx                    1.14-alpine     8a2fb25a19f5   4 years ago      16MB

查看配置是否更改

[root@localhost ~]# docker inspect rep/user:v3.0
[{"Id": "sha256:ac68fbf602d6e2271e6c96bfea658899acbb7ba74a2e83044b90e50666b48e78","RepoTags": ["rep/user:v3.0"],"RepoDigests": [],"Parent": "sha256:16ea53ea7c652456803632d67517b78a4f9075a10bfdc4fc6b7b4cbf2bc98497","Comment": "","Created": "2024-02-08T08:35:17.347089055Z","Container": "b59d841d65102533088e703838bd3df3ab582a816644c369b703fd03f60b4d4a","ContainerConfig": {"Hostname": "b59d841d6510","Domainname": "","User": "","AttachStdin": true,"AttachStdout": true,"AttachStderr": true,"Tty": true,"OpenStdin": true,"StdinOnce": true,"Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd": ["sh"],"Image": "busybox","Volumes": null,"WorkingDir": "","Entrypoint": null,"OnBuild": null,"Labels": {}},"DockerVersion": "20.10.8","Author": "user<6666@qq.com>","Config": {"Hostname": "b59d841d6510","Domainname": "","User": "","AttachStdin": true,"AttachStdout": true,"AttachStderr": true,"Tty": true,"OpenStdin": true,"StdinOnce": true,"Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd": ["/bin/httpd","-f","-h","/data/html/"],"Image": "busybox","Volumes": null,"WorkingDir": "","Entrypoint": null,"OnBuild": null,"Labels": {}},"Architecture": "amd64","Os": "linux","Size": 1235989,"VirtualSize": 1235989,"GraphDriver": {"Data": {"LowerDir": "/var/lib/docker/overlay2/1d3ee61fa87959f86ffcdc962b53b312f4990382fb2c800708019c8472c8041a/diff","MergedDir": "/var/lib/docker/overlay2/156150a591d65edb67085d724f3aca64803258c434ced16eba09255477f75907/merged","UpperDir": "/var/lib/docker/overlay2/156150a591d65edb67085d724f3aca64803258c434ced16eba09255477f75907/diff","WorkDir": "/var/lib/docker/overlay2/156150a591d65edb67085d724f3aca64803258c434ced16eba09255477f75907/work"},"Name": "overlay2"},"RootFS": {"Type": "layers","Layers": ["sha256:cfd97936a58000adc09a9f87adeeb7628a2c71d11c4998e6e7f26935fa0cd713","sha256:58e02db36919351af6ebda7ac2644efa7cafdb3608e78d67fe63290a38990707"]},"Metadata": {"LastTagTime": "2024-02-08T03:35:17.3524158-05:00"}}
]

4、启动镜像

[root@localhost ~]# docker run --name t6 rep/user:v3.0

5、查看启动容器ip

[root@localhost ~]# docker inspect t6
[{"Id": "33ec9c548bfd0e6b439ae45dfde4b57e7c7b69b71a32f94ef5554b9e0df9c6ef","Created": "2024-02-08T08:37:33.895339149Z","Path": "/bin/httpd","Args": ["-f","-h","/data/html/"],"State": {"Status": "running","Running": true,"Paused": false,"Restarting": false,"OOMKilled": false,"Dead": false,"Pid": 3113,"ExitCode": 0,"Error": "","StartedAt": "2024-02-08T08:37:34.38201913Z","FinishedAt": "0001-01-01T00:00:00Z"},"Image": "sha256:ac68fbf602d6e2271e6c96bfea658899acbb7ba74a2e83044b90e50666b48e78","ResolvConfPath": "/var/lib/docker/containers/33ec9c548bfd0e6b439ae45dfde4b57e7c7b69b71a32f94ef5554b9e0df9c6ef/resolv.conf","HostnamePath": "/var/lib/docker/containers/33ec9c548bfd0e6b439ae45dfde4b57e7c7b69b71a32f94ef5554b9e0df9c6ef/hostname","HostsPath": "/var/lib/docker/containers/33ec9c548bfd0e6b439ae45dfde4b57e7c7b69b71a32f94ef5554b9e0df9c6ef/hosts","LogPath": "/var/lib/docker/containers/33ec9c548bfd0e6b439ae45dfde4b57e7c7b69b71a32f94ef5554b9e0df9c6ef/33ec9c548bfd0e6b439ae45dfde4b57e7c7b69b71a32f94ef5554b9e0df9c6ef-json.log","Name": "/t6","RestartCount": 0,"Driver": "overlay2","Platform": "linux","MountLabel": "","ProcessLabel": "","AppArmorProfile": "","ExecIDs": null,"HostConfig": {"Binds": null,"ContainerIDFile": "","LogConfig": {"Type": "json-file","Config": {}},"NetworkMode": "default","PortBindings": {},"RestartPolicy": {"Name": "no","MaximumRetryCount": 0},"AutoRemove": false,"VolumeDriver": "","VolumesFrom": null,"CapAdd": null,"CapDrop": null,"CgroupnsMode": "host","Dns": [],"DnsOptions": [],"DnsSearch": [],"ExtraHosts": null,"GroupAdd": null,"IpcMode": "private","Cgroup": "","Links": null,"OomScoreAdj": 0,"PidMode": "","Privileged": false,"PublishAllPorts": false,"ReadonlyRootfs": false,"SecurityOpt": null,"UTSMode": "","UsernsMode": "","ShmSize": 67108864,"Runtime": "runc","ConsoleSize": [0,0],"Isolation": "","CpuShares": 0,"Memory": 0,"NanoCpus": 0,"CgroupParent": "","BlkioWeight": 0,"BlkioWeightDevice": [],"BlkioDeviceReadBps": null,"BlkioDeviceWriteBps": null,"BlkioDeviceReadIOps": null,"BlkioDeviceWriteIOps": null,"CpuPeriod": 0,"CpuQuota": 0,"CpuRealtimePeriod": 0,"CpuRealtimeRuntime": 0,"CpusetCpus": "","CpusetMems": "","Devices": [],"DeviceCgroupRules": null,"DeviceRequests": null,"KernelMemory": 0,"KernelMemoryTCP": 0,"MemoryReservation": 0,"MemorySwap": 0,"MemorySwappiness": null,"OomKillDisable": false,"PidsLimit": null,"Ulimits": null,"CpuCount": 0,"CpuPercent": 0,"IOMaximumIOps": 0,"IOMaximumBandwidth": 0,"MaskedPaths": ["/proc/asound","/proc/acpi","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/timer_list","/proc/timer_stats","/proc/sched_debug","/proc/scsi","/sys/firmware"],"ReadonlyPaths": ["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"GraphDriver": {"Data": {"LowerDir": "/var/lib/docker/overlay2/32516427ad632cfc78a84d39ba0b17551a3242cbc8fdb3c7a32a264dd28ca05e-init/diff:/var/lib/docker/overlay2/156150a591d65edb67085d724f3aca64803258c434ced16eba09255477f75907/diff:/var/lib/docker/overlay2/1d3ee61fa87959f86ffcdc962b53b312f4990382fb2c800708019c8472c8041a/diff","MergedDir": "/var/lib/docker/overlay2/32516427ad632cfc78a84d39ba0b17551a3242cbc8fdb3c7a32a264dd28ca05e/merged","UpperDir": "/var/lib/docker/overlay2/32516427ad632cfc78a84d39ba0b17551a3242cbc8fdb3c7a32a264dd28ca05e/diff","WorkDir": "/var/lib/docker/overlay2/32516427ad632cfc78a84d39ba0b17551a3242cbc8fdb3c7a32a264dd28ca05e/work"},"Name": "overlay2"},"Mounts": [],"Config": {"Hostname": "33ec9c548bfd","Domainname": "","User": "","AttachStdin": false,"AttachStdout": true,"AttachStderr": true,"Tty": false,"OpenStdin": false,"StdinOnce": false,"Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd": ["/bin/httpd","-f","-h","/data/html/"],"Image": "rep/user:v3.0","Volumes": null,"WorkingDir": "","Entrypoint": null,"OnBuild": null,"Labels": {}},"NetworkSettings": {"Bridge": "","SandboxID": "19fd1b6c96beb856720a7308137b8a68811cadaf9381ee964ded4341cec32b73","HairpinMode": false,"LinkLocalIPv6Address": "","LinkLocalIPv6PrefixLen": 0,"Ports": {},"SandboxKey": "/var/run/docker/netns/19fd1b6c96be","SecondaryIPAddresses": null,"SecondaryIPv6Addresses": null,"EndpointID": "b0e8a95b41d4362018942961d47615ab6cad056565b95f5eba4a2f7b433937d3","Gateway": "172.17.0.1","GlobalIPv6Address": "","GlobalIPv6PrefixLen": 0,"IPAddress": "172.17.0.2","IPPrefixLen": 16,"IPv6Gateway": "","MacAddress": "02:42:ac:11:00:02","Networks": {"bridge": {"IPAMConfig": null,"Links": null,"Aliases": null,"NetworkID": "1dacca69e1651440892c19ca1297000fdf80ae51f33c02ec5f53d20753b1ebb0","EndpointID": "b0e8a95b41d4362018942961d47615ab6cad056565b95f5eba4a2f7b433937d3","Gateway": "172.17.0.1","IPAddress": "172.17.0.2","IPPrefixLen": 16,"IPv6Gateway": "","GlobalIPv6Address": "","GlobalIPv6PrefixLen": 0,"MacAddress": "02:42:ac:11:00:02","DriverOpts": null}}}}
]

6、curl 容器ip地址,可以看到配置生效

[root@localhost ~]# curl 172.17.0.2
<h1>welcome to busybox<h1>

二、给容器打标签

[root@localhost ~]# docker tag --helpUsage:  docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

1、用法 docker tag 源标签 新标签

如果没有标签,源标签用IMAGE ID如下图

2、通过image_id命令来打标签

docker tag 160a180ce384 rep/user1:v4.0

3. 通过标签,替换标签命令如下

docker tag rep/user1:v4.0 rep/user2:v5.0

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/675183.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ubuntu22.04 安装部署05:禁用默认显卡驱动

一、相关文章 ubuntu22.04安装部署03&#xff1a; 设置root密码-CSDN博客 《ubuntu22.04装部署01&#xff1a;禁用内核更新》 《ubuntu22.04装部署02&#xff1a;禁用显卡更新》 二、场景说明 Ubuntu22.04 默认显卡驱动&#xff0c;如果安装cuda&#xff0c;需要单独安装显…

Android开发 button 按钮点击两次 响应onclick方法

问题 Android开发 button 按钮点击两次 响应onclick方法 详细问题 笔者xml代码 <!-- 一个按钮 --> <Button android:id"id/button1" android:layout_width"wrap_conten…

模型环境备份

很多时候&#xff0c;在调试新环境的时候&#xff0c;需要对环境进行保存备份&#xff0c;然后为后面的环境复原做好准备 综合建议 备份环境&#xff1a;在进行这些更改之前&#xff0c;如果您在使用虚拟环境&#xff08;强烈推荐&#xff09;&#xff0c;可以考虑先导出当前…

Conda历史版本下载地址和python对应关系

一、前言 因为Conda安装版本问题&#xff0c;带来了很多问题&#xff0c;虽然不能直接确定二者之间的关系&#xff0c;但是安装指定版本的conda,确实是一个比较好的方法。特此记忆。 二、下载地址 下载最新版本&#xff1a;Free Download | Anaconda 下载历史版本&#xff…

Kafka系列之:Kafka集群同时设置基于时间和日志大小两种方式保存Topic的数据

Kafka系列之:Kafka集群同时设置基于时间和日志大小两种方式保存Topic的数据 一、基于日志大小二、基于时间大小三、参数设置四、设置命令一、基于日志大小 "log.retention.bytes"是Apache Kafka中的一项配置参数,用于指定每个日志段文件的最大大小。当日志段文件的…

利用低代码 BI 平台获得竞争优势:实现数据分析与业务决策的革新

介绍 疫情迫使企业优先考虑数字化转型。由于公司被迫参加计划外的数字化速成课程&#xff0c;这种文化转变将数字技术的采用加速了数年。 转向数字解决方案已成倍增加了跨行业生成的数据量。大量数据可以更好地了解运营、客户和市场&#xff0c;还可以推动任何组织的创新。 …

Xcode配置GLFW GLAD (MAC)

这里的GLFW用的是静态链接 博主反复修改&#xff0c;实在是没能找到为什么用动态会出现线程报错 下载GLAD:版本我一般是选倒数第二新&#xff0c;profile记得选core 点击GENRATE 点glad.zip获得下载 下载GLFW 点击download 最后&#xff0c;将两个文件都放到项目里面去 打开…

DataX源码分析 TaskGroupContainer

系列文章目录 一、DataX详解和架构介绍 二、DataX源码分析 JobContainer 三、DataX源码分析 TaskGroupContainer 四、DataX源码分析 TaskExecutor 五、DataX源码分析 reader 六、DataX源码分析 writer 七、DataX源码分析 Channel 文章目录 系列文章目录TaskGroupContainer初始…

形态学操作之开操作与闭操作的python实现——数字图像处理

原理 图像处理中的开操作&#xff08;Opening&#xff09;和闭操作&#xff08;Closing&#xff09;是形态学&#xff08;Morphological&#xff09;操作的两个基本类型&#xff0c;它们都是基于膨胀&#xff08;Dilation&#xff09;和腐蚀&#xff08;Erosion&#xff09;操…

JAVA面试题11

什么是Java的访问修饰符&#xff0c;并列出它们的作用。 Java的访问修饰符包括public、private、protected和默认。它们的作用如下&#xff1a; public: 可以被任何其他类访问。 private: 只能被所在类访问&#xff0c;其他类无法访问。 protected: 可以被所在类和同一个包中的…

基于PHP的学生管理系统

前言 基于PHP的学生管理系统&#xff1b; 实现 登录、注册、学生信息、修改学生、删除学生、查询学生、添加学生等功能 &#xff1b; 环境准备 开发平台&#xff1a;PhpStrom2022.1.2 、Phpstudy_pro 数据库&#xff1a;MySQL5.7.26 技术架构 Bootstrap PHP7.3.4html5css3 项目…

系统架构21 - 统一建模语言UML(下)

UML图 UML中的图分类作用 视图用例视图逻辑视图进程视图实现视图部署视图 UML中的图 “图”是一组元素的图形表示&#xff0c;大多数情况下把图画成顶点&#xff08;代表事物&#xff09;和弧&#xff08;代表关系&#xff09;的连通图。为了对系统进行可视化&#xff0c;可以…

Vue-60、Vue技术编程式路由

编程式路由导航 1、作用&#xff1a;不借助实现路由跳转&#xff0c;让路由跳转更加灵活 2、具体编码 pushShow(p){this.$router.push({name:xiangqing,query:{id:p.id,title:p.title}})},replaceShow(p){this.$router.replace({name:xiangqing,query:{id:p.id,title:p.titl…

运维高级篇-分库分表(拆分策略详解)

分库分表 介绍 问题分析 随着互联网及移动互联网的发展&#xff0c;应用系统的数据量也是成指数式增长&#xff0c;若采用单数据库进行数据存 储&#xff0c;存在以下性能瓶颈&#xff1a; IO瓶颈&#xff1a;热点数据太多&#xff0c;数据库缓存不足&#xff0c;产生大量磁盘…

堆的数据结构以及堆的相应操作

堆的定义 二叉树中的堆使用顺序存储的结构来进行存储这里的堆指代的是一种数据结构 在一个关键码存在的集合中K {K1,K2,K3,....,Kn},把它的所有元素按照完全二叉树的顺序存储方式&#xff0c;存储在一个一维数组中&#xff0c;如果根结点的元素值大于其左右孩子的值&#xf…

关节点检测

https://www.bilibili.com/video/BV19g4y1777q/?p2&spm_id_frompageDriver 关节点检测全流程 YOLO:单阶段&#xff0c;快&#xff1b; MMPose&#xff1a;双阶段&#xff0c;准&#xff1b; 标注工具Labelme 用Labelme标注样本数据集

方格定位1_题解

【题解提供者】吴立强 解法 思路 将原数减 1 后看作是四进制数&#xff0c;那么十位代表的就是所在行号减 1 的值&#xff0c;个位代表的就是所在列号减 1 的值。 代码展示 #include <iostream> using namespace std;int main() {int n; cin >> n;int h (n …

MongoDB聚合: $sortByCount

$sortByCount聚合根据指定表达式的值对输入文档进行分组&#xff0c;然后计算每个不同分组中的文档数。 每个输出文档包含两个字段&#xff1a;一个是包含不同分组值的_id字段&#xff0c;另一个是包含属于该分组或类别的文档数量的计数字段。 文档按计数降序排序。 语法 {…

常用的文件系统、存储类型小整理

最近接触到了五花八门的文件系统、存储类型&#xff0c;名词听得头大&#xff0c;趁假期整理学习一番~ 名称OSSFastDFSJuiceFSCIFSCephFSEFSNFS全称Object Storage Service (对象存储服务)Fast Distributed File System (快速分布式文件系统)Juice File System (Juice 文件系统…

电脑通电自启动设置

首先要进入BIOS&#xff0c;以华硕为例&#xff0c;按下电源键&#xff0c;在开机之前按下delete键&#xff0c;其他电脑可能是esc或者某个f键&#xff0c;请自行查找。 进入BIOS后要找到电源管理&#xff0c;可以在高级选项中找一找&#xff0c;如上图右下角选择高级模式。 …