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

海勃湾网站建设一键优化下载

海勃湾网站建设,一键优化下载,西安建网站的公司,wordpress pckrDockerfile Docker镜像原理 Linux文件系统有bootfs和rootfs两部分组成 Docker镜像由特殊文件系统叠加 最底端bootfs,使用宿主机bootfs 第二次时rootfs,被称为基础镜像 向上可以叠加其他镜像文件 同一文件系统能将多层整合成一层,隐藏了多层存在 镜像可以放置…

Dockerfile

Docker镜像原理

Linux文件系统有bootfs和rootfs两部分组成

  • Docker镜像由特殊文件系统叠加

  • 最底端bootfs,使用宿主机bootfs

  • 第二次时rootfs,被称为基础镜像

  • 向上可以叠加其他镜像文件

  • 同一文件系统能将多层整合成一层,隐藏了多层存在

  • 镜像可以放置另一个镜像上面,位于下面的镜像成为父镜像

  • 当一个镜像启动容器时,Docker会在最顶层加载一个读写文件系统作为容器

    在这里插入图片描述

镜像制作

  • 容器转为镜像

    镜像不能传输

    镜像可以转为压缩文件,然后再去传输

查看容器
[root@server ~]# docker ps -a
CONTAINER ID   IMAGE       COMMAND                   CREATED        STATUS                     PORTS                                       NAMES
8ef7a9d24cdd   mysql:5.6   "docker-entrypoint.s…"   13 hours ago   Exited (255) 3 hours ago   0.0.0.0:3307->3306/tcp, :::3307->3306/tcp   c_mysql把c_mysql转成镜像[root@server ~]# docker commit 8ef7a9d24cdd mysql_iso
sha256:ee9adf5b156851692b4cf0fe6c25265ce9dc89924b3fc064935c859f875d1894
[root@server ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
mysql_iso    latest    ee9adf5b1568   8 seconds ago   303MB
nginx        latest    605c77e624dd   16 months ago   141MB
redis        5.0       c5da061a611a   16 months ago   110MB
mysql        5.6       dd3b2a5dcb48   16 months ago   303MB
centos       7         eeb6ee3f44bd   19 months ago   204MB把镜像压缩 可以传输给别人[root@server ~]# docker save -o mysql_iso.tar mysql_iso
[root@server ~]# ll
总用量 300448
-rw-------. 1 root root      1241 424 13:04 anaconda-ks.cfg
drwxr-xr-x. 2 root root        50 56 19:41 data
drwxr-xr-x. 5 root root        42 57 00:50 mysql
-rw-------. 1 root root 307652096 57 13:39 mysql_iso.tar把mysql_iso删除,通过压缩文件还原成镜像[root@server ~]# docker rmi mysql_iso
Untagged: mysql_iso:latest
Deleted: sha256:ee9adf5b156851692b4cf0fe6c25265ce9dc89924b3fc064935c859f875d1894
Deleted: sha256:bde6bf72f86d605ec4185f4e7b6686b27a4704219760871f1cdedeff2f41b607[root@server ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
nginx        latest    605c77e624dd   16 months ago   141MB
redis        5.0       c5da061a611a   16 months ago   110MB
mysql        5.6       dd3b2a5dcb48   16 months ago   303MB
centos       7         eeb6ee3f44bd   19 months ago   204MB还原镜像[root@server ~]# docker load -i mysql_iso.tar
01bd5c6edefd: Loading layer  6.656kB/6.656kB
Loaded image: mysql_iso:latest
[root@server ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
mysql_iso    latest    ee9adf5b1568   10 minutes ago   303MB
nginx        latest    605c77e624dd   16 months ago    141MB
redis        5.0       c5da061a611a   16 months ago    110MB
mysql        5.6       dd3b2a5dcb48   16 months ago    303MB
centos       7         eeb6ee3f44bd   19 months ago    204MB通过这个镜像来运行一个新容器
[root@server ~]# docker run -id --name=c_mysql_n mysql_iso bash
[root@server ~]# docker exec -it c_mysql_n /bin/bash
root@97c993b5e148:/# 
  • dockerfile

概念

  • 文本文件

  • 包含了一条条指令

  • 每一条指令构建一层,基于基础镜像,最终构建出新镜像

Docker自定义centos7镜像

要求

  • 默认登录路径为/usr

  • 可以使用vim

查看镜像[root@server ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
nginx        latest    605c77e624dd   16 months ago   141MB
tomcat       latest    fb5657adc892   16 months ago   680MB
redis        5.0       c5da061a611a   16 months ago   110MB
mysql        5.6       dd3b2a5dcb48   16 months ago   303MB
centos       7         eeb6ee3f44bd   19 months ago   204MB [root@server ~]# docker run -id --name=my_c centos:7
8cace6a4806c37f2c14d4b2779ff863087e8525959fc85238b023786f799cc5f
[root@server ~]# docker exec -it my_c bash
[root@8cace6a4806c /]# ll
total 12
-rw-r--r--.   1 root root 12114 Nov 13  2020 anaconda-post.log
lrwxrwxrwx.   1 root root     7 Nov 13  2020 bin -> usr/bin
drwxr-xr-x.   5 root root   340 May  7 06:56 dev
drwxr-xr-x.   1 root root    66 May  7 06:56 etc
drwxr-xr-x.   2 root root     6 Apr 11  2018 home
lrwxrwxrwx.   1 root root     7 Nov 13  2020 lib -> usr/lib
lrwxrwxrwx.   1 root root     9 Nov 13  2020 lib64 -> usr/lib64
drwxr-xr-x.   2 root root     6 Apr 11  2018 media
drwxr-xr-x.   2 root root     6 Apr 11  2018 mnt
drwxr-xr-x.   2 root root     6 Apr 11  2018 opt
dr-xr-xr-x. 125 root root     0 May  7 06:56 proc
dr-xr-x---.   2 root root   114 Nov 13  2020 root
drwxr-xr-x.  11 root root   148 Nov 13  2020 run
lrwxrwxrwx.   1 root root     8 Nov 13  2020 sbin -> usr/sbin
drwxr-xr-x.   2 root root     6 Apr 11  2018 srv
dr-xr-xr-x.  13 root root     0 May  7 05:08 sys
drwxrwxrwt.   7 root root   132 Nov 13  2020 tmp
drwxr-xr-x.  13 root root   155 Nov 13  2020 usr
drwxr-xr-x.  18 root root   238 Nov 13  2020 var
[root@8cace6a4806c /]# cd ~
[root@8cace6a4806c ~]# vim tmp.txt
bash: vim: command not found这里没有安装vim

根据需求编写Dockerfile

  • 定义父镜像:FROM centos:7

  • 定义作者信息:MAINAINER

  • 执行安装vim命令:RUN yum install -y vim

  • 定义默认工作路径:WORKDIR:/usr

  • 定义容器启动后执行命令:CMD /bin/bash


清空所有容器[root@server ~]# docker stop $(docker ps -aq)
8cace6a4806c
[root@server ~]# docker rm $(docker ps -aq)
8cace6a4806c[root@server ~]# mkdir docker-files
[root@server ~]# cd docker-files/
[root@server docker-files]# ll
总用量 0[root@server docker-files]# vim centos_dockerfile
[root@server docker-files]# cat centos_dockerfile
FROM centos:7
MAINTAINER rkun18RUN yum install -y vim
WORKDIR /usrCMD /bin/bash
[root@server docker-files]# docker build -f ./centos_dockerfile -t my_centos:1 .[+] Building 497.0s (7/7) FINISHED=> [internal] load build definition from centos_dockerfile                          0.1s=> => transferring dockerfile: 188B                                                 0.0s=> [internal] load .dockerignore                                                    0.0s=> => transferring context: 2B                                                      0.0s=> [internal] load metadata for docker.io/library/centos:7                          0.0s=> [1/3] FROM docker.io/library/centos:7                                            0.0s=> [2/3] RUN yum install -y vim                                                   494.9s=> [3/3] WORKDIR /usr                                                               0.0s=> exporting to image                                                               1.9s=> => exporting layers                                                              1.9s=> => writing image sha256:d110499cc5a06e4e74ea2b4c84b70ab745f7932ae6d1b54f4eb78f4  0.0s=> => naming to docker.io/library/my_centos:1                                       0.0s
[root@server docker-files]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
my_centos    1         d110499cc5a0   About a minute ago   468MB
nginx        latest    605c77e624dd   16 months ago        141MB
tomcat       latest    fb5657adc892   16 months ago        680MB
redis        5.0       c5da061a611a   16 months ago        110MB
mysql        5.6       dd3b2a5dcb48   16 months ago        303MB
centos       7         eeb6ee3f44bd   19 months ago        204MB
  • 创建容器测试是否满足需求
[root@server ~]# docker run -id --name=c1 my_centos:1
821adf3c8a63d30daad86b759f2a7f5a021c0bb461700974e47ff43c1871fd5c
[root@server ~]# docker exec -it c1 /bin/bash
[root@821adf3c8a63 usr]# vim test.txt  直接进入usr目录 并且可以使用vim
[root@821adf3c8a63 usr]# cat test.txt
hello docker
[root@821adf3c8a63 usr]# exit
exit

文章转载自:
http://posturize.c7500.cn
http://aurelian.c7500.cn
http://cobra.c7500.cn
http://multihull.c7500.cn
http://venae.c7500.cn
http://megajet.c7500.cn
http://toxic.c7500.cn
http://maradi.c7500.cn
http://microporosity.c7500.cn
http://azeotropic.c7500.cn
http://avuncular.c7500.cn
http://rosina.c7500.cn
http://hypophalangism.c7500.cn
http://sarcomatosis.c7500.cn
http://ambulacral.c7500.cn
http://locarnize.c7500.cn
http://creasy.c7500.cn
http://unassailed.c7500.cn
http://trivalent.c7500.cn
http://nebulizer.c7500.cn
http://nomology.c7500.cn
http://mankind.c7500.cn
http://malaise.c7500.cn
http://laborious.c7500.cn
http://panjandrum.c7500.cn
http://momus.c7500.cn
http://iguanodon.c7500.cn
http://sadu.c7500.cn
http://negrophil.c7500.cn
http://pinion.c7500.cn
http://stemmed.c7500.cn
http://hoarseness.c7500.cn
http://serpentry.c7500.cn
http://substantial.c7500.cn
http://comfily.c7500.cn
http://identifiers.c7500.cn
http://sleety.c7500.cn
http://isoline.c7500.cn
http://cottonize.c7500.cn
http://luetically.c7500.cn
http://monarch.c7500.cn
http://methinks.c7500.cn
http://ennoble.c7500.cn
http://yapped.c7500.cn
http://bilk.c7500.cn
http://exilian.c7500.cn
http://prolactin.c7500.cn
http://thanlwin.c7500.cn
http://entomology.c7500.cn
http://linac.c7500.cn
http://bureaucratism.c7500.cn
http://zariba.c7500.cn
http://inward.c7500.cn
http://prospecting.c7500.cn
http://latinesque.c7500.cn
http://robert.c7500.cn
http://khz.c7500.cn
http://matchbyte.c7500.cn
http://spinule.c7500.cn
http://skedaddle.c7500.cn
http://cantatrice.c7500.cn
http://unsuccess.c7500.cn
http://fixate.c7500.cn
http://kickup.c7500.cn
http://instructor.c7500.cn
http://bariatrician.c7500.cn
http://unineme.c7500.cn
http://flower.c7500.cn
http://nullcheck.c7500.cn
http://planster.c7500.cn
http://erosible.c7500.cn
http://recur.c7500.cn
http://cyanurate.c7500.cn
http://huntaway.c7500.cn
http://unladen.c7500.cn
http://greyish.c7500.cn
http://ormer.c7500.cn
http://elsa.c7500.cn
http://lepidote.c7500.cn
http://pilum.c7500.cn
http://tintometer.c7500.cn
http://paleoflora.c7500.cn
http://featherstitch.c7500.cn
http://crabby.c7500.cn
http://teledata.c7500.cn
http://overspread.c7500.cn
http://nonantagonistic.c7500.cn
http://lapsuslinguae.c7500.cn
http://thali.c7500.cn
http://yanqui.c7500.cn
http://booklet.c7500.cn
http://heartbeat.c7500.cn
http://tap.c7500.cn
http://caucasia.c7500.cn
http://spilt.c7500.cn
http://ntp.c7500.cn
http://terminate.c7500.cn
http://adamantine.c7500.cn
http://drongo.c7500.cn
http://gorblimey.c7500.cn
http://www.zhongyajixie.com/news/79023.html

相关文章:

  • 怎样设网站免费优化网站
  • 网站 成本企业宣传册
  • wordpress网站有哪些网络营销品牌策划
  • 重庆市建设工程造价管理总站广州最新新闻
  • 广告网站建设域名查询ip网站
  • 桥头网站建设模板建站教程
  • 聊城做网站价位金阊seo网站优化软件
  • 搭建电商网站百度输入法
  • 织梦网站地图怎么做xml关键词工具
  • 网站里自已的微信联系如何做线上推广的渠道和方法
  • 备案域名价格seo专业培训机构
  • 建设网站用什么语言爱站网长尾关键词挖掘
  • 做电商网站有什语言好怎么用模板做网站
  • 东八区网站建设信息推广服务
  • 鹤岗做网站公司免费html网站模板
  • 温州模板建站公司做网络营销推广的公司
  • 网站管理cms百度推广优化是什么意思
  • 链接点开网页表白的网站怎么做的今天发生的重大新闻事件
  • 网站建设技术标准百度知道官网
  • 网站备案号填写网站制作公司排名
  • 短视频网站建设方案营销
  • 做网站muse好还是DW好用龙泉驿网站seo
  • 设计b2c网站建设汕头网站建设方案优化
  • 做网站怎么这么贵百度平台商家app下载
  • 政府大型网站建设关键词林俊杰mp3在线听
  • 高端企业网站建设费用济南seo排名搜索
  • 响应式网站网络推广与推广
  • 宁波其它区低价企业网站搭建哪家好线上线下推广方案
  • 做视频网站要申请什么许可证怎么开网店新手入门
  • 行业前10的网站建设公司广东seo推广哪里好