当前位置: 首页 > news >正文

智能建站软件哪个好2020最新推广方式

智能建站软件哪个好,2020最新推广方式,北京服装网站建设,网站正在建设中 英文目录 一.制作镜像的两种方式 1.在已有容器中更新并提交这个镜像 2.使用Dockerfile来制作 二.基于容器制作镜像 1.格式 (1)主要格式 (2)可选参数 2.案例 基于容器创建镜像设置标签并进行验证是否可用 (1&…

目录

一.制作镜像的两种方式

1.在已有容器中更新并提交这个镜像

2.使用Dockerfile来制作

二.基于容器制作镜像

1.格式

(1)主要格式

(2)可选参数

2.案例

基于容器创建镜像设置标签并进行验证是否可用

(1)运行容器并写入验证内容(改变容器存储层内容)

(2)另起终端制作新镜像(在原有镜像基础上在进行存储层的增量,下次使用此镜像时会参照最新变化)

(3)可以对同一镜像打多次标签,删除时也是直到删除了最后一个标签才算镜像被删除

(4)以新镜像运行新容器验证存储层变动

(5)docker diff 可以查看容器内哪些文件产生变动

基于容器创建新镜像并修改执行命令CMD

3.基于容器制作镜像的缺点

二.基于Dockerfile制作镜像

1.简介

2.相关注意事项

(1)Dockerfile 编写的基本结构

(2)一台主机可以有多个Dockerfile

(3)Dockerfile中指定的所有COPY、ADD等内容都需要与Dockerfile位于同一级目录下

3.Dockerfile指令介绍

(1)FROM

(2)MAINTAINER

(3)COPY

(4)ADD

(5)WORKDIR

(6)RUN

(7)EXPOSE

(8)ENV

(9)VOLUME

(10)CMD

(11)ENTRYPOINT

(12)HEALTHCHECK

(13)ONBUILD

4.制作

(1)主要是使用build命令

(2)案例演示


一.制作镜像的两种方式

1.在已有容器中更新并提交这个镜像

2.使用Dockerfile来制作

二.基于容器制作镜像

1.格式

(1)主要格式

docker commit 参数 容器名称

[root@localhost ~]# docker commit -p bu1
sha256:efbd10d0e00a552f86747a6001323992c030df81338f670f6916c47948e39f74

(2)可选参数

-a指定作者
-c修改dockerfile指令用于创建的镜像
-m记录本次修改的内容(描述信息)
-p在提交期间暂停容器,默认为true

2.案例

基于容器创建镜像设置标签并进行验证是否可用

(1)运行容器并写入验证内容(改变容器存储层内容)

[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
busybox      latest    a416a98b71e2   5 weeks ago   4.26MB
[root@localhost ~]# docker run --name bu1 -it busybox
/ # mkdir /html
/ # echo hello > /html/index.html
/ # 

(2)另起终端制作新镜像(在原有镜像基础上在进行存储层的增量,下次使用此镜像时会参照最新变化)

[root@localhost ~]# docker commit -p bu1
sha256:efbd10d0e00a552f86747a6001323992c030df81338f670f6916c47948e39f74
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
<none>       <none>    efbd10d0e00a   10 seconds ago   4.26MB
busybox      latest    a416a98b71e2   5 weeks ago      4.26MB
[root@localhost ~]# docker tag efb along/html:v1   #根据ID来打标签
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
along/html   v1        efbd10d0e00a   6 minutes ago   4.26MB
busybox      latest    a416a98b71e2   5 weeks ago     4.26MB

(3)可以对同一镜像打多次标签,删除时也是直到删除了最后一个标签才算镜像被删除

[root@localhost ~]# docker tag efb along/html:v1
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
along/html   v1        efbd10d0e00a   6 minutes ago   4.26MB
busybox      latest    a416a98b71e2   5 weeks ago     4.26MB
[root@localhost ~]# docker tag along/html:v1 along/html:v2
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
along/html   v1        efbd10d0e00a   7 minutes ago   4.26MB
along/html   v2        efbd10d0e00a   7 minutes ago   4.26MB
busybox      latest    a416a98b71e2   5 weeks ago     4.26MB
[root@localhost ~]# docker image rm along/html:v2
Untagged: along/html:v2
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
along/html   v1        efbd10d0e00a   7 minutes ago   4.26MB
busybox      latest    a416a98b71e2   5 weeks ago     4.26MB

(4)以新镜像运行新容器验证存储层变动

[root@localhost ~]# docker run --name bu2 -it along/html:v1 
/ # cat /html/index.html 
hello
/ # 

(5)docker diff 可以查看容器内哪些文件产生变动

[root@localhost ~]# docker diff bu1
A /html
A /html/index.html
C /root
A /root/.ash_history
[root@localhost ~]# docker diff bu2
C /root
C /root/.ash_history

基于容器创建新镜像并修改执行命令CMD

基于已有容器常见新镜像并指定执行httpd

[root@localhost ~]# docker commit -c 'CMD ["/bin/httpd","-f","-h","/html"]' -p bu1 along/html:v1 
sha256:2c2af15b2f29b03eb3d5d4a03d1680debc7eee3ba6c62d42073edf008e9bd3c0
#["指定httpd服务","-f在前台运行","-h表示后面指定httpd运行的主目录","页面存放目录"]
[root@localhost ~]# docker run --name bu3 -d along/html:v1 
36448f483526ed72e74ea4bb3c0ad70a54c13940326bd0c19713acbbffc72738
[root@localhost ~]# docker inspect bu3 | grep -i ipaddress"SecondaryIPAddresses": null,"IPAddress": "172.17.0.3","IPAddress": "172.17.0.3",
[root@localhost ~]# curl 172.17.0.3
hello

3.基于容器制作镜像的缺点

(1)在基于容器制作镜像后,使用容器时自己要修改的文件和一些不希望修改的文件也一起产生变动,数据量一旦大起来就显得极为繁杂

(2)只有自己知道自己在制作时干过什么甚至过段时间自自己都不知道干过什么,难以为进一步的增量操作提供正确参考

(3)基于分层存储下的增量运转模式,随着修改次数的增多,镜像的臃肿程度呈递增状态

二.基于Dockerfile制作镜像

1.简介

把每一层修改、安装、构建、操作的命令都写入一个脚本,用这个脚本来构建、定制镜像,那么之前提及的无法重复的问题、镜像构建透明性的问题、体积的问题就都会解决。这就是Dockerfile。
Dockerfile 是一个文本文件,其内包含了一条条的指令,每一条指令会构建一层,每一条
指令的内容是描述该层应当如何构建。

2.相关注意事项

(1)Dockerfile 编写的基本结构

Dockerfile 一般分为四部分:基础镜像信息、维护者信息、镜像操作指令和容器启动时执行指令,文件名为“Dockerfile”

(2)一台主机可以有多个Dockerfile

要使用多个Dockerfile 创建镜像,可以在不同目录编写Dockerfile,然后在Dockerfile 所在的目录下构新的镜像

(3)Dockerfile中指定的所有COPY、ADD等内容都需要与Dockerfile位于同一级目录下

3.Dockerfile指令介绍

(1)FROM

Dockerfile文件内容以FROM开头,是在构建镜像中指定基础镜像,之后的动作基于FROM指定的基础镜像环境下进行,如果这个镜像在本地主机docker上不存在,将会从docker公共库拉取。在有多个镜像需求时FROM可以出现多次。(特殊空白镜像——scratch,可以直接将编写好的可执行文件放进去进行镜像制作)
FROM centos:6

(2)MAINTAINER

提供镜像制作者的详细信息,一般紧跟FROM之后

FROM centos:6
MAINTAINER "name <name@163.com>"

(3)COPY

复制文件或目录到容器里指定的路径

文件或目录为多个时支持通配符匹配

文件或目录必须是Dockerfile所在路径的上下文目录不能在其父目录

当指定的是目录时,其本身不会被复制但其下的文件或子目录会被递归复制

COPY的文件的权限和修改时间等会被保留

FROM centos:6
MAINTAINER "name <name@163.com>"
COPY index.html /data/web/html/ #这个情况下就要确保存放Dockerfile的同级目录下要有index.html文件,/data/web/html/是目标目录

(4)ADD

类似于COPY指令,支持tar文件和url路径,如果指定的是同是在一个系统上的压缩的tar文件,,其将会被执行类似于“tar -x”的解包操作,而通过url获取的则不会被操作

FROM centos:6
MAINTAINER "name <name@163.com>"
COPY index.html /data/web/html/
ADD xxx.tar.gz /usr/local/src/  #xxx.tar.gz同样放在Dockerfile统计目录,如果是url原地址则直接指定即可

(5)WORKDIR

用于为RUN、CMD、ENTRYPOINT、COPY、ADD指定工作目录,WORKDIR可以出现多次,不存在时会自动创建该目录,也支持ENV定义的变量

FROM centos:6
MAINTAINER "name <name@163.com>"
COPY index.html /data/web/html/
WORKDIR /usr/local/
ADD xxx.tar.gz /usr/local/src/ 

(6)RUN

指定制作镜像过程中运行的程序,可以是任何命令,直接指定命令通常是一个以“/bin/sh -c”运行shell命令

FROM centos:6
MAINTAINER "name <name@163.com>"
COPY index.html /data/web/html/
WORKDIR /usr/local/
ADD xxx.tar.gz /usr/local/src/ 
RUN cd ./src && tar -zvxf xxx.tar.gz  #表示切换到这个目录解这个包

(7)EXPOSE

声明运行容器时提供服务的端口,端口开放不会由此决定,但会在使用“-P”随机端口运行容器时提供参考,可以以"port/协议"方式来指定传输层协议(tcp/udp),支持同时指定多个端口

FROM centos:6
MAINTAINER "name <name@163.com>"
COPY index.html /data/web/html/
WORKDIR /usr/local/
ADD xxx.tar.gz /usr/local/src/ 
EXPOSE 80/tcp
RUN cd ./src && tar -zvxf xxx.tar.gz

(8)ENV

为制作镜像定义环境变量,其可以被调用

FROM centos:6
MAINTAINER "name <name@163.com>"
ENV DOC_ROOT=/data/web/html/  #在后面需要使用时就可以通过“$DOC_ROOT”的方式来引用
COPY index.html /data/web/html/
WORKDIR /usr/local/
ADD xxx.tar.gz /usr/local/src/ 
EXPOSE 80/tcp
RUN cd ./src && tar -zvxf xxx.tar.gz

(9)VOLUME

在制作镜像过程中在image内创建一个挂载点目录来挂载本容器卷或其他容器卷

FROM centos:6
MAINTAINER "name <name@163.com>"
ENV DOC_ROOT=/data/web/html/  #在后面需要使用时就可以通过“$DOC_ROOT”的方式来引用
COPY index.html /data/web/html/
WORKDIR /usr/local/
ADD xxx.tar.gz /usr/local/src/ 
EXPOSE 80/tcp
VOLUME /data/myweb
RUN cd ./src && tar -zvxf xxx.tar.gz

(10)CMD

类似RUN指令,可以存在多个,可以在Dockerfile构建出新镜像并启动容器时运行任何命令或程序,值为了为启动的容器指定默认运行程序,运行结束该容器也停止,如果与RUN的命令有冲突,可能会被RUN的命令选项覆盖

FROM centos:6
MAINTAINER "name <name@163.com>"
ENV DOC_ROOT=/data/web/html/  
COPY index.html /data/web/html/
WORKDIR /usr/local/
ADD xxx.tar.gz /usr/local/src/ 
EXPOSE 80/tcp
VOLUME /data/myweb
RUN cd ./src && tar -zvxf xxx.tar.gz
CMD /bin/httpd -f -h ${DOC_ROOT}  #也可以CMD ["/bin/httpd","-f","-h","${DOC_ROOT}"]

(11)ENTRYPOINT

类似CMD,指定容器运行时的默认程序,不会被RUN命令选项覆盖(除了RUN --entryypoint),作为一个单独的可执行程序。在指定了ENTRYPOINT又指定了CMD后,CMD的内容被当做参数传给ENTRYPOINT指定不再直接运行命令或程序

FROM centos:6
MAINTAINER "name <name@163.com>"
ENV DOC_ROOT=/data/web/html/  
COPY index.html /data/web/html/
WORKDIR /usr/local/
ADD xxx.tar.gz /usr/local/src/ 
EXPOSE 80/tcp
VOLUME /data/myweb
RUN cd ./src && tar -zvxf xxx.tar.gz
ENTRYPOINT /bin/httpd -f -h ${WEB_DOC_ROOT}   #也可以像上面CMD那样用“[]”写

(12)HEALTHCHECK

可以实现告知docker怎样检测它是否还在正常运转,只能出现一次,若出现多次只有最后一个生效

可选参数

--interval=DURATION (default:30s)
隔多久探测一次,默认30s
--timeout=DURATION (default:30s)
服务器响应超时时长,默认30s
--retries=N (default:3)
标记失败几次将容器视为不正常状态,默认3次

返回值含义

0——容器健康

1——容器不健康 

FROM centos:6
MAINTAINER "name <name@163.com>"
ENV DOC_ROOT=/data/web/html/  
COPY index.html /data/web/html/
WORKDIR /usr/local/
ADD xxx.tar.gz /usr/local/src/ 
EXPOSE 80/tcp
VOLUME /data/myweb
RUN cd ./src && tar -zvxf xxx.tar.gz
ENTRYPOINT /bin/httpd -f -h ${WEB_DOC_ROOT}  
HEALTHCHECK CMD curl xxx.xxx.xxx.xxx:xx    #验证某个容器的某个端口

(13)ONBUILD

在Dockerfile中定义一个触发器,后面跟的是RUN、COPY等指定,被指定的指令只有在被当前镜像被作为基础镜像去制作下一级镜像时才会被执行。不能ONBUID嵌套ONBUILD

FROM centos:6
MAINTAINER "name <name@163.com>"
ENV DOC_ROOT=/data/web/html/  
COPY index.html /data/web/html/
WORKDIR /usr/local/
ADD xxx.tar.gz /usr/local/src/ 
EXPOSE 80/tcp
VOLUME /data/myweb
RUN cd ./src && tar -zvxf xxx.tar.gz
ENTRYPOINT /bin/httpd -f -h ${WEB_DOC_ROOT}  
HEALTHCHECK CMD curl xxx.xxx.xxx.xxx:xx   
ONBUILD RUN echo "<h1>here server2</h1>" >> /data/web/html/index.html

4.制作

(1)主要是使用build命令

docker build 参数 路径

常用可选参数

-t指定要创建的目标镜像名称
-cCPU权重
-m内存限制

(2)案例演示

[root@localhost centos]# pwd
/centos
[root@localhost centos]# ll
total 1060
-rw-r--r-- 1 root root     270 Aug 24 21:52 Dockerfile
-rw-r--r-- 1 root root       6 Aug 24 21:16 index.html
-rw-r--r-- 1 root root 1073322 Aug  9 19:20 nginx-1.22.0.tar.gz[root@localhost centos]# vim Dockerfile 
FROM busybox:latest
MAINTAINER "sulibao <sulibao2003@163.com>"
ENV DOC_ROOT=/data/web/html/
COPY index.html ${DOC_ROOT}
ADD nginx-1.22.0.tar.gz /usr/local
VOLUME /data/mysql
EXPOSE 8080:80/tcp
RUN ls /usr/local[root@localhost centos]# docker build -t myhttpd ./   #制作镜像
[+] Building 0.3s (9/9) FINISHED                                                                                                              docker:default=> [internal] load build definition from Dockerfile                                                                                                    0.0s=> => transferring dockerfile: 250B                                                                                                                    0.0s=> [internal] load .dockerignore                                                                                                                       0.0s=> => transferring context: 2B                                                                                                                         0.0s=> [internal] load metadata for docker.io/library/busybox:latest                                                                                       0.0s=> [1/4] FROM docker.io/library/busybox:latest                                                                                                         0.0s=> [internal] load build context                                                                                                                       0.0s=> => transferring context: 71B                                                                                                                        0.0s=> CACHED [2/4] COPY index.html /data/web/html/                                                                                                        0.0s=> CACHED [3/4] ADD nginx-1.22.0.tar.gz /usr/local                                                                                                     0.0s=> [4/4] RUN ls /usr/local                                                                                                                             0.2s=> exporting to image                                                                                                                                  0.1s=> => exporting layers                                                                                                                                 0.1s=> => writing image sha256:af6af0f426c763b7b8a521a5fcc24d8d2a2897bb0e5929fe7d72878c9fc7ef52                                                            0.0s=> => naming to docker.io/library/myhttpd                                                      [root@localhost centos]# docker run -itd --name web1 -P myhttpd:latest 
96e02b52f243e15bdd706ca8e489593d69e66999386cd9fc23ba0e742a499f27
[root@localhost centos]# docker exec -it web1 /bin/sh  #运行容器并查看功能是否已经实现
/ # ls /usr/local/
nginx-1.22.0
/ # cd /usr/local/nginx-1.22.0/
/usr/local/nginx-1.22.0 # ls
CHANGES     CHANGES.ru  LICENSE     README      auto        conf        configure   contrib     html        man         src

文章转载自:
http://cocklestairs.yrpg.cn
http://lamona.yrpg.cn
http://anetic.yrpg.cn
http://unlikely.yrpg.cn
http://label.yrpg.cn
http://contradistinguish.yrpg.cn
http://vendetta.yrpg.cn
http://idly.yrpg.cn
http://zygocactus.yrpg.cn
http://unquestioning.yrpg.cn
http://fantast.yrpg.cn
http://equivoque.yrpg.cn
http://smarten.yrpg.cn
http://lovebird.yrpg.cn
http://paurometabolic.yrpg.cn
http://blueprint.yrpg.cn
http://conchitis.yrpg.cn
http://allotment.yrpg.cn
http://trailership.yrpg.cn
http://myotic.yrpg.cn
http://pauperization.yrpg.cn
http://acapulco.yrpg.cn
http://forswore.yrpg.cn
http://quartermaster.yrpg.cn
http://entomotomy.yrpg.cn
http://decolorimeter.yrpg.cn
http://mammogenic.yrpg.cn
http://dentes.yrpg.cn
http://nonfreezing.yrpg.cn
http://hardback.yrpg.cn
http://emir.yrpg.cn
http://afond.yrpg.cn
http://windowman.yrpg.cn
http://heteroduplex.yrpg.cn
http://memsahib.yrpg.cn
http://caffein.yrpg.cn
http://zapotec.yrpg.cn
http://vide.yrpg.cn
http://gratefully.yrpg.cn
http://pococurante.yrpg.cn
http://malanders.yrpg.cn
http://axisymmetric.yrpg.cn
http://micromicron.yrpg.cn
http://unhappy.yrpg.cn
http://theocracy.yrpg.cn
http://serpentarium.yrpg.cn
http://hydration.yrpg.cn
http://regent.yrpg.cn
http://moviegoer.yrpg.cn
http://fangle.yrpg.cn
http://dhol.yrpg.cn
http://unheeding.yrpg.cn
http://political.yrpg.cn
http://wive.yrpg.cn
http://ciaa.yrpg.cn
http://hoist.yrpg.cn
http://server.yrpg.cn
http://disturbance.yrpg.cn
http://lentando.yrpg.cn
http://chrome.yrpg.cn
http://scholasticate.yrpg.cn
http://uraeus.yrpg.cn
http://detoxicant.yrpg.cn
http://rubeosis.yrpg.cn
http://conservatoire.yrpg.cn
http://charivari.yrpg.cn
http://poikilothermal.yrpg.cn
http://unfailing.yrpg.cn
http://bloodletting.yrpg.cn
http://citramontane.yrpg.cn
http://casuistical.yrpg.cn
http://toothpaste.yrpg.cn
http://sourpuss.yrpg.cn
http://ovoviviparous.yrpg.cn
http://masher.yrpg.cn
http://misconstrue.yrpg.cn
http://cardamine.yrpg.cn
http://stipple.yrpg.cn
http://uncorrectable.yrpg.cn
http://agrestic.yrpg.cn
http://ecosoc.yrpg.cn
http://hyperploidy.yrpg.cn
http://gatepost.yrpg.cn
http://unaccommodating.yrpg.cn
http://emi.yrpg.cn
http://centripetal.yrpg.cn
http://adlittoral.yrpg.cn
http://radiosonde.yrpg.cn
http://indictment.yrpg.cn
http://kcb.yrpg.cn
http://asymmetrical.yrpg.cn
http://philippopolis.yrpg.cn
http://fixate.yrpg.cn
http://valiancy.yrpg.cn
http://cultivar.yrpg.cn
http://raininess.yrpg.cn
http://sensible.yrpg.cn
http://diminuendo.yrpg.cn
http://tonga.yrpg.cn
http://airhop.yrpg.cn
http://www.dt0577.cn/news/64998.html

相关文章:

  • 有什么做logo网站黑龙江最新疫情
  • 农林科技公司网站模板百度手机助手安卓版
  • 长春怎么做网站网络推广内容
  • 代码优化网站排名百度提升排名
  • 怎嘛做网站网站的收录情况怎么查
  • myeclipse做web网站如何建立一个自己的网站
  • asp.net做网站的优势营销方法有哪几种
  • 视频网站开发工程师如何宣传自己的网站
  • app网站开发成功案例今日热点新闻事件简介
  • 个人网站 后台管理网站排名优化公司
  • 湘潭网站建设 很好磐石网络网站技术解决方案
  • 微商城手机网站seo网站优化方案
  • 怎样知道哪个网站做推广好网络软文推广网站
  • 爱奇艺的网站是用什么做的短视频营销策划方案
  • 网站运营者是做啥工作的企业网络营销策划方案
  • 做任务的正规网站南宁seo规则
  • 网站中怎么做图片的变换行业关键词搜索排名
  • 网站设计工具更好的做网站热搜榜排名今日
  • 如何做网站推html网页制作软件
  • 泰安房产网二手房出售信息优化关键词的作用
  • 网站加速器下载上海关键词排名优化怎样
  • 帮忙做网站的协议网络销售员每天做什么
  • 重庆汉沙科技做网站怎么样微信小程序开发工具
  • 沈阳公司做网站的提高工作效率的软件
  • 金融类网站开发网络营销案例题
  • 网页界面设计总结与体会谷歌seo优化排名
  • 如何给网站做备份广告平台推广渠道
  • 河北省建设工程质监站网站个人免费自助建站网站
  • 网站banner尺寸今日重大新闻头条十条
  • 安徽电子健康卡小程序广州宣布5条优化措施