日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

编写Dockerfile增强centos镜像:安装vim 和net-tools

發布時間:2025/1/21 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 编写Dockerfile增强centos镜像:安装vim 和net-tools 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

批量刪除正在運行的docker容器

docker rm -f $(docker ps -q)

#刪除正在運行的容器 -q是容器ID docker rm -f $(docker ps -q)docker run -it centos /bin/bash [root@c35acdee94f5 /]# pwd / [root@c35acdee94f5 /]# vim 1.txt bash: vim: command not found [root@c35acdee94f5 /]#

增強centos鏡像

Dockerfile腳本內容

FROM centos MAINTAINER zxl ENV MYPATH /usr/local WORKDIR $MYPATH RUN yum -y install vim RUN yum -y install net-tools EXPOSE 80 CMD echo $MYPATH CMD echo "success--------------------ok" CMD /bin/bash

自定義Dockerfile腳本名稱

docker build -f /workspace/docker/Dockerfile_mycentos -t mycentos:1.0 .

#構建日志分析docker build -f /workspace/docker/Dockerfile_mycentos -t mycentos:1.0 .Sending build context to Docker daemon 2.048kB Step 1/10 : FROM centos---> 831691599b88 Step 2/10 : MAINTAINER zxl---> Running in e07788688d45 Removing intermediate container e07788688d45---> a82dcc01fd28 Step 3/10 : ENV MYPATH /usr/local---> Running in 41025cc720ea Removing intermediate container 41025cc720ea---> c8a228cfb683 Step 4/10 : WORKDIR $MYPATH---> Running in d5886ae1db81 Removing intermediate container d5886ae1db81---> a8a64debc724 Step 5/10 : RUN yum -y install vim---> Running in 6aff19c80e35Removing intermediate container 6aff19c80e35---> 305e52dde1a4 Step 6/10 : RUN yum -y install net-tools---> Running in 65cedbfcbd04Removing intermediate container 65cedbfcbd04---> 4205f2211f78 Step 7/10 : EXPOSE 80---> Running in 4587d06aa791 Removing intermediate container 4587d06aa791---> 33c9f36fedd5 Step 8/10 : CMD echo $MYPATH---> Running in 67121426d7bd Removing intermediate container 67121426d7bd---> e9dfce53a5cf Step 9/10 : CMD echo "success--------------------ok"---> Running in f04f2b2cee9a Removing intermediate container f04f2b2cee9a---> af402f3387d7 Step 10/10 : CMD /bin/bash---> Running in e81a287c288a Removing intermediate container e81a287c288a---> 512d695d8553 Successfully built 512d695d8553 Successfully tagged mycentos:1.0

docker images REPOSITORY TAG IMAGE ID CREATED SIZE mycentos 1.0 512d695d8553 About a minute ago 295MB centos latest 831691599b88 6 weeks ago 215MB

基于自定義centos鏡像運行容器

vim和ifconfig的命令都支持了。

docker run -it mycentos:1.0 /bin/bash[root@03dbfdb30935 local]# pwd /usr/local [root@03dbfdb30935 local]# vim 1.txt [root@03dbfdb30935 local]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 172.17.0.2 netmask 255.255.0.0 broadcast 172.17.255.255ether 02:42:ac:11:00:02 txqueuelen 0 (Ethernet)RX packets 26 bytes 4558 (4.4 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0loop txqueuelen 1000 (Local Loopback)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[root@03dbfdb30935 local]#

docker history命令

docker images REPOSITORY TAG IMAGE ID CREATED SIZE mycentos 1.0 512d695d8553 12 minutes ago 295MB centos latest 831691599b88 6 weeks ago 215MBdocker history 512d695d8553 IMAGE CREATED CREATED BY SIZE COMMENT 512d695d8553 12 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "/bin… 0B af402f3387d7 12 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "echo… 0B e9dfce53a5cf 12 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "echo… 0B 33c9f36fedd5 12 minutes ago /bin/sh -c #(nop) EXPOSE 80 0B 4205f2211f78 12 minutes ago /bin/sh -c yum -y install net-tools 22.8MB 305e52dde1a4 13 minutes ago /bin/sh -c yum -y install vim 57.2MB a8a64debc724 14 minutes ago /bin/sh -c #(nop) WORKDIR /usr/local 0B c8a228cfb683 14 minutes ago /bin/sh -c #(nop) ENV MYPATH=/usr/local 0B a82dcc01fd28 14 minutes ago /bin/sh -c #(nop) MAINTAINER zxl 0B 831691599b88 6 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B <missing> 6 weeks ago /bin/sh -c #(nop) LABEL org.label-schema.sc… 0B <missing> 6 weeks ago /bin/sh -c #(nop) ADD file:84700c11fcc969ac0… 215MB

總結

以上是生活随笔為你收集整理的编写Dockerfile增强centos镜像:安装vim 和net-tools的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。