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

news/2024/2/24 7:19:12/文章来源:https://blog.csdn.net/QWERTY55555/article/details/136080279

一、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.luyixian.cn/news_show_963363.aspx

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

相关文章

【JVM篇】ThreadLocal中为什么要使用弱引用

文章目录 &#x1f354;ThreadLocal中为什么要使用弱引用⭐总结 &#x1f354;ThreadLocal中为什么要使用弱引用 ThreadLocal可以在线程中存放线程的本地变量&#xff0c;保证数据的线程安全 ThreadLocal是这样子保存对象的&#xff1a; 在每个线程中&#xff0c;存放了一个…

3D高斯溅射:面向三维场景的实时渲染技术

1. 前言 高斯溅射技术【1】一经推出&#xff0c;立刻引起学术界和工业界的广泛关注。相比传统的隐式神经散射场渲染技术&#xff0c;高斯溅射依托椭球空间&#xff0c;显性地表示多目图像的三维空间关系&#xff0c;其计算效率和综合性能均有较大的提升&#xff0c;且更容易理…

Java+SpringBoot:高校竞赛管理新篇章

✍✍计算机编程指导师 ⭐⭐个人介绍&#xff1a;自己非常喜欢研究技术问题&#xff01;专业做Java、Python、微信小程序、安卓、大数据、爬虫、Golang、大屏等实战项目。 ⛽⛽实战项目&#xff1a;有源码或者技术上的问题欢迎在评论区一起讨论交流&#xff01; ⚡⚡ Java实战 |…

使用client-only 解决组件不兼容SSR问题

目录 前言 一、解决方案 1.基于Nuxt 框架的SSR应用 2.基于vue2框架的应用 3.基于vue3框架的应用 二、总结 往期回顾 前言 最近在我的单页面SSR应用上开发JSON编辑器功能&#xff0c;在引入组件后直接客户端跳转OK&#xff0c;但是在直接加载服务端渲染的时候一直报这…

【flink状态管理(三)】StateBackend的整体设计、StateBackend创建说明

文章目录 一. 状态后端概述二. StateBackend的整体设计1. 核心功能2. StateBackend的UML3. 小结 三. StateBackend的加载与初始化1. StateBackend创建概述2. StateBackend创建过程 一. 状态后端概述 StateBackend作为状态存储后端&#xff0c;提供了创建和获取KeyedStateBacke…

postgresql 手动清理wal日志的101个坑

新年的第一天&#xff0c;总结下去年遇到的关于WAL日志清理的101个坑&#xff0c;以及如何相对安全地进行清理。前面是关于WAL日志堆积的原因分析&#xff0c;清理相关可以直接看第三部分。 首先说明&#xff0c;手动清理wal日志是一个高风险的操作&#xff0c;尤其对于带主从的…

前端vite+vue3——自动化配置路由布局

文章目录 ⭐前言&#x1f496;vue3系列文章 ⭐ 自动化配置路由&#x1f496;引入vite版本自定义目录映射&#x1f496;自动化读取文件下的路由&#x1f496;main入口加载路由&#x1f496;入口app.vue配置&#x1f496;layout基础布局配置&#x1f496;效果 ⭐总结⭐结束 ⭐前言…

搜索二维矩阵[中等]

一、题目 给你一个满足下述两条属性的m x n整数矩阵&#xff1a; 【1】每行中的整数从左到右按非严格递增顺序排列。 【2】每行的第一个整数大于前一行的最后一个整数。 给你一个整数target&#xff0c;如果target在矩阵中&#xff0c;返回true&#xff1b;否则&#xff0c;返…

【Linux技术宝典】Linux入门:揭开Linux的神秘面纱

文章目录 官网Linux 环境的搭建方式一、什么是Linux&#xff1f;二、Linux的起源与发展三、Linux的核心组件四、Linux企业应用现状五、Linux的发行版本六、为什么选择Linux&#xff1f;七、总结 Linux&#xff0c;一个在全球范围内广泛应用的开源操作系统&#xff0c;近年来越来…

树莓派编程基础与硬件控制

1.编程语言 Python 是一种泛用型的编程语言&#xff0c;可以用于大量场景的程序开发中。根据基于谷歌搜 索指数的 PYPL&#xff08;程序语言流行指数&#xff09;统计&#xff0c;Python 是 2019 年 2 月全球范围内最为流行 的编程语言 相比传统的 C、Java 等编程语言&#x…

生成树技术华为ICT网络赛道

9.生成树 目录 9.生成树 9.1.生成树技术概述 9.2.STP的基本概念及工作原理 9.3.STP的基础配置 9.4.RSTP对STP的改进 9.5.生成树技术进阶 9.1.生成树技术概述 技术背景&#xff1a;二层交换机网络的冗余性与环路 典型问题1&#xff1a;广播风暴 典型问题2&#xff1a;MA…

《UE5_C++多人TPS完整教程》学习笔记10 ——《P11 设置加入游戏会话(Setup for Joining Sessions)》

本文为B站系列教学视频 《UE5_C多人TPS完整教程》 —— 《P11 设置加入游戏会话&#xff08;Setup for Joining Sessions&#xff09;》 的学习笔记&#xff0c;该系列教学视频为 Udemy 课程 《Unreal Engine 5 C Multiplayer Shooter》 的中文字幕翻译版&#xff0c;UP主&…

Linux开发:PAM1 介绍

PAM(Pluggable Authentication Modules )是Linux提供的一种通用的认证方式,他可以根据需要动态的加载认证模块,从而减少认证开发的工作量以及提供认证的灵活度。 1.PAM的框架 PAM的框架由一下几个部分构成 1)应用程序,即需要使用认证服务的程序,这些应用程序是使用抽象…

单例模式 C++

6 种 单例 的手写&#xff0c;都是懒汉&#xff08;饿汉代码在 “懒汉 / 饿汉的区别”&#xff09; 目录 ✊前言 &#x1f33c;GPT解析 &#x1f33c;概念解析 RAII 懒汉 / 饿汉的区别 特点 举例 单例 -- 伪代码 适用场景 单例 -- 实现方式 优缺点 &#x1f382;手…

【Iceberg学习二】Branch和Tag在Iceberg中的应用

Iceberg 表元数据保持一个快照日志&#xff0c;记录了对表所做的更改。快照在 Iceberg 中至关重要&#xff0c;因为它们是读者隔离和时间旅行查询的基础。为了控制元数据大小和存储成本&#xff0c;Iceberg 提供了快照生命周期管理程序&#xff0c;如 expire_snapshots&#xf…

《Linux 简易速速上手小册》第9章: 备份与恢复策略(2024 最新版)

文章目录 9.1 理解备份的重要性9.1.1 重点基础知识9.1.2 重点案例&#xff1a;数据中心遭受火灾9.1.3 拓展案例&#xff1a;个人电脑硬盘故障9.1.4 企业级数据库被恶意软件加密 9.2 实施备份策略9.2.1 重点基础知识9.2.2 重点案例&#xff1a;为中小企业实施备份策略9.2.3 拓展…

springboot165科研工作量管理系统的设计与实现

简介 【毕设源码推荐 javaweb 项目】基于springbootvue 的 适用于计算机类毕业设计&#xff0c;课程设计参考与学习用途。仅供学习参考&#xff0c; 不得用于商业或者非法用途&#xff0c;否则&#xff0c;一切后果请用户自负。 看运行截图看 第五章 第四章 获取资料方式 **项…

基于SpringBoot+Vue的服装销售商城系统

末尾获取源码作者介绍&#xff1a;大家好&#xff0c;我是墨韵&#xff0c;本人4年开发经验&#xff0c;专注定制项目开发 更多项目&#xff1a;CSDN主页YAML墨韵 学如逆水行舟&#xff0c;不进则退。学习如赶路&#xff0c;不能慢一步。 目录 一、项目简介 二、开发技术与环…

bert-vits2本地部署报错疑难问题汇总

环境&#xff1a; bert-vits2.3 win 和wsl 问题描述&#xff1a; bert-vits2本地部署报错疑难问题汇总 解决方案&#xff1a; 问题1: Conda安装requirements里面依赖出现ERROR: No matching distribution found for opencc1.1.6 解决方法 需要在 Python 3.11 上使用 Op…

linux服务器如何提高游戏帧率?

在Linux服务器上&#xff0c;由于硬件配置和系统的限制&#xff0c;提高游戏帧率变得更加困难。但是通过一些优化和调整&#xff0c;我们仍然可以提升Linux服务器上的游戏性能。 首先我们需要了解游戏帧率与服务器性能之间的关系。游戏帧率是指游戏每秒渲染的帧数&#xff0c;…