[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
前言
Docker容器卷是一个特殊目录,它存放在宿主机的文件系统中,可供一个或多个容器使用。这种卷绕过了联合文件系统(Union File
System),可以提供很多有用的特性。例如,对数据卷的修改会立即生效,对数据卷的更新不会影响镜像,此外,数据卷会在容器被删除后依然存在。
卷的本质是文件或者目录,其设计目的就是解决数据的持久化问题,使得数据独立于容器的生存周期。这样即使容器被删除,对应的数据文件也不会消失,从而实现了数据
persistency。
docker run:
docker run :创建一个新的容器并运行一个命令,是将镜像放入容器并启动容器。
docker run一般需要跟几个参数,如下所示:
docker run -d -v /root/:/root/:ro -v /etc/:/etc/ -v /var/log/:/var/log/ -v
/etc/localtime:/etc/localtime:ro --net=host --privileged=true --name
neutron-deployment xxxxxx /bin/bash -c "while true; do ls /root ;sleep 1;done"
举个例子,前面的 /root/ 是宿主机目录,后面的 /root/ 是容器内的目录。这个命令将宿主机的 /root/ 目录挂载到容器的 /root/
目录上,并且以只读方式(:ro)进行挂载。 之后的root目录下文件,宿主机跟容器就是双向同步了。xxxx是镜像名称,自行修改。
-i: 以交互模式运行容器,通常与 -t 同时使用;
-t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用;
–name: 为容器指定一个名称;
-p: 指定端口映射,格式为:主机(宿主)端口:容器端口;
-e: 设置环境变量;
-d:运行的镜像名,并返回容器ID;
但是有时候我们是用kubectl apply 来拉起镜像
在yaml中
注意下面的containers下面的
volumeMounts是容器中的目录,下面的volumes是宿主机中的目录,他们的名字name要一致,相当于也是跟docker run一样的效果
containers: - workingDir: /apps/conf name: neutron-server image: xxxxxx
imagePullPolicy: IfNotPresent volumeMounts: - mountPath: /etc/passwd name:
sys-passwd readOnly: true - mountPath: /etc/shadow name: sys-shadow readOnly:
true volumes: - name: sys-passwd hostPath: path: /etc/passwd - name: sys-shadow
hostPath: path: /etc/shadow