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.rhkb.cn/news/253697.html

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

相关文章

16:定时器和计数器

定时器和计数器 1、定时器和计数器的介绍2、定时器是如何工作3、寄存器4、51单片机定时器简介&#xff08;数据手册&#xff09;5、定时器中的寄存器&#xff08;数据手册&#xff09;5.1、TCON&#xff08;定时器控制寄存器&#xff09;5.2、TMOD&#xff08;工作模式寄存器&a…

Bootstrap5 响应式导航栏

Bootstrap5 响应式导航栏 我们可以使用 Bootstrap5 导航栏组件为网站或应用程序创建响应式导航标题。 这些响应式导航栏在手机等小视口的设备上会折叠&#xff0c;但当用户单击切换按钮时会展开。 但是&#xff0c;它在中型和大型设备&#xff08;例如笔记本电脑或台式机&#…

元宇宙虚拟数字人实训室:推动高校培养创新技术人才

随着元宇宙时代的到来&#xff0c;虚拟数字人技术逐渐成为当下火热的产业赛道之一。虚拟数字人涉及了计算机、数字媒体、市场营销等学科技术领域&#xff0c;高校可以通过搭建元宇宙虚拟数字人实训室&#xff0c;有效培养对元宇宙行业的专业化理解和研究能力的专业型创新人才。…

寒假作业-day5

1>现有无序序列数组为23,24,12,5,33,5347&#xff0c;请使用以下排序实现编程 函数1:请使用冒泡排序实现升序排序 函数2:请使用简单选择排序实现升序排序 函数3:请使用直接插入排序实现升序排序 函数4:请使用插入排序实现升序排序 代码&#xff1a; #include<stdio.h&g…

【UE】游戏运行流程的简单理解

流程图 官方的游戏流程图&#xff1a; 一般顺序为初始化引擎、创建并初始化 GameInstance、加载关卡&#xff0c;最后开始游戏。 总的来说就是&#xff1a; 开始游戏-》游戏实例-》关卡-》游戏模式-》玩家控制器-》Pawn、玩家状态、HUD、UMG&#xff08;可有可无&#xff09; …

蓝桥杯-求阶乘-python

问题描述 满足N!的末尾恰好有K个0的最小的N是多少&#xff1f; 如果这样的N不存在输出一1。 思路解析 末尾的0是由10产生的&#xff0c;而10是由质数2和5产生的 在求阶乘的过程中&#xff0c;只要是偶数就会有2&#xff0c;而5相对2更少&#xff0c;所以对于10的数量我们可以…

Angular BaseView抽离页面公用属性

前言 如果有一系列的页面布局很类似&#xff0c;为了节省时间&#xff0c;我们可以把这些类似的页面所通用的属性和方法抽离成一个BaseView&#xff0c;让其它页面继承该基础页面&#xff0c;同时将一些经常改变的属性和差异的属性写到配置文件里。例如树容器初始时是否展开、…

学习 Redis 基础数据结构,不讲虚的。

学习 Redis 基础数据结构&#xff0c;不讲虚的。 一个群友给我发消息&#xff0c;“该学的都学了&#xff0c;怎么就找不到心意的工作&#xff0c;太难了”。 很多在近期找过工作的同学一定都知道了&#xff0c;背诵八股文已经不是找工作的绝对王牌。企业最终要的是可以创造价…

免费生成ios证书的方法(无需mac电脑)

使用hbuilderx的uniapp框架开发移动端程序很方便&#xff0c;可以很方便地开发出移动端的小程序和app。但是打包ios版本的app的时候却很麻烦&#xff0c;官方提供的教程需要使用mac电脑来生成证书&#xff0c;但是mac电脑却不便宜&#xff0c;一般的型号都差不多上万。 因此&a…

Quicker读取浏览器的书签(包括firefox火狐)

从edge换了火狐&#xff0c;但是quicker不能读取本地的bookmarks文件了&#xff0c;就研究了一下。 方法1&#xff1a;读取本地Bookmarks文件&#xff08;仅谷歌内核浏览器&#xff09; 谷歌内核的浏览器本地会有Bookmarks文件&#xff0c;放了所有的书签数据&#xff0c;直接…

泰克示波器(TBS2000系列)数学运算功能使用

目录 1 数学运算菜单1.1 运算符选择1.2 信源选择1.3 数学运算结果 1 数学运算菜单 Math运算按钮&#xff0c;用于实现对两个通道的信号进行实时的“加、减、乘”运算&#xff0c;计算时信源1在前面&#xff0c;信源2在运算符的右边&#xff0c;设置时设置信源与运算符就行了。…

HCIA-HarmonyOS设备开发认证V2.0-3.轻量系统内核基础

目录 一、前言二、LiteOS-M系统概述三、内核框架3.1、CMSIS 和 POSIX 整体架构3.2、LiteOS-M内核启动流程 四、内核基础4.1、任务管理4.2、时间管理(待续)4.3、中断管理(待续)4.4、软件定时器(待续) 五、内存管理5.1、静态内存(待续)5.2、动态内存(待续) 六、内核通信机制6.1、…

CentOS镜像如何下载?在VMware中如何安装?

一、问题 CentOS镜像如何下载&#xff1f;在VMware中如何安装&#xff1f; 二、解决 1、CentOS镜像的下载 &#xff08;1&#xff09;官方网站 The CentOS Project &#xff08;2&#xff09;官方中文官网 CentOS 中文 官网 &#xff08;3&#xff09;选择CentOS Linux…

16.docker删除redis缓存数据、redis常用基本命令

1.进入redis容器内部 &#xff08;1&#xff09;筛选过滤出redis容器 docker ps | grep "redis"&#xff08;2&#xff09;进入redis容器 #说明&#xff1a;d24为redis容器iddocker exec -it d24 /bin/bash2.登陆redis (1) 进入redis命令行界面 redis-cli说明&a…

备战蓝桥杯---搜索(进阶1)

话不多说&#xff0c;直接看题&#xff1a; 没有传送带时&#xff0c;我们可以直接BFS&#xff0c;但因为传送带的出现&#xff0c;可能在队列里的元素到起点时间不单调的问题&#xff0c;而BFS本来就是可以看成随着时间推移而产生的情况&#xff0c;于是我们把队列看成优先队列…

黑马程序员——html css基础——day09——CSS高级

目录&#xff1a; 定位 相对定位&#xff1a;绝对定位定位居中固定定位堆叠层级z-index高级技巧 CSS精灵案例-写出自己的名字字体图标下载字体使用字体CSS修饰属性 垂直对齐方式过渡表单获得焦点选择器focus透明度opacity光标类型cursor禁用鼠标样式表格样式-合并相邻两个边框…

Redis篇之分布式锁

一、为什么要使用分布式锁 1.抢劵场景 &#xff08;1&#xff09;代码及流程图 &#xff08;2&#xff09;抢劵执行的正常流程 就是正好线程1执行完整个操作&#xff0c;线程2再执行。 &#xff08;3&#xff09;抢劵执行的非正常流程 因为线程是交替进行的&#xff0c;所以有…

Vagrant 虚拟机工具基本操作指南

Vagrant 虚拟机工具基本操作指南 ​#虚拟机 #​ ​#vargant#​ ​#ubuntu#​ ‍ 虚拟机virtualbox ,VMWare及WSL等大家都很了解了&#xff0c;那Vagrant是什么东西&#xff1f; 它是一组命令行工具&#xff0c;可以象Docker管理容器一样管理虚拟机&#xff0c;这样快速创…

Java代码实现基数排序算法(附带源码)

基数排序是一种非比较型整数排序算法&#xff0c;其原理是将整数按位数切割成不同的数字&#xff0c;然后按每个位数分别比较。由于整数也可以表达字符串&#xff08;比如名字或日期&#xff09;和特定格式的浮点数&#xff0c;所以基数排序也不是只能使用于整数。 1. 基数排序…

缓存组件Caffeine的使用

caffeine是一个高性能的缓存组件&#xff0c;在需要缓存数据&#xff0c;但数据量不算太大&#xff0c;不想引入redis的时候&#xff0c;caffeine就是一个不错的选择。可以把caffeine理解为一个简单的redis。 1、导入依赖 <!-- https://mvnrepository.com/artifact/com.git…