首页 > 其他分享 >docker——存储配置与管理

docker——存储配置与管理

时间:2024-04-23 17:25:14浏览次数:25  
标签:管理 root 存储配置 data hmm test docker local

docker存储配置与管理

查看docker info

[root@hmm overlay2]# docker info
Client: Docker Engine - Community
 Version:    25.0.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.6
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 5
 Server Version: 25.0.3
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 3.10.0-862.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 1.936GiB
 Name: hmm
 ID: ef4c910e-c299-4bde-b4b8-e6bd39ec99ee
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  http://registry.docker-cn.com/
 Live Restore Enabled: false

WARNING: API is accessible on http://0.0.0.0:2375 without encryption.
         Access to the remote API is equivalent to root access on the host. Refer
         to the 'Docker daemon attack surface' section in the documentation for
         more information: https://docs.docker.com/go/attack-surface/
[root@hmm overlay2]# 

查看驱动的本地存储

[root@hmm ~]# ls /var/lib/docker/
buildkit  containers  engine-id  image  network  overlay2  plugins  runtimes  swarm  tmp  volumes
[root@hmm ~]# cd  /var/lib/docker/
[root@hmm docker]# cd overlay2/
[root@hmm overlay2]# ls
26625907d00815747e8cac482a1a62ff06e153543cf914c4edf95d0846b15ec5
3d8c300ff053bd2ca4e62612c8209dd2e8358845228b4a76aab105358afa37ab
51056850a6566edcd8c8e3a0cd507cb4ca421463e18203782c4aa8515dabc146
51056850a6566edcd8c8e3a0cd507cb4ca421463e18203782c4aa8515dabc146-init
5ef601e966da6df616f65b262570adbb5733017d770d94c5bc8c7e6b188ad881
7987fae3b1b5590b9c0d4d8e38011c6715df2026231afe3c37382200b9b1a1ff
97l4r6nxwu2mpz0n0cxlr973v
backingFsBlockDev
db0600235154dccf95a6a3ad038fe630024448364895e81409ccb072c07269e2
e41egh7ju6i7x0o7qrvk4gy4k
f7c270ad6461a794e6e169c944fdd2cb6d13456859100d83d9a6937c1ee5dbb7
hyqu74kjsemkx24bv71cfyhqk
l
lgnbtonjnna4nt95y2ume8l5i
[root@hmm overlay2]# 

修改damon.json文件,更改存储驱动

[root@hmm overlay2]# cat /etc/docker/daemon.json 
{
  "registry-mirrors":["http://registry.docker-cn.com"],
   "storage-driver": "vfs"
}
[root@hmm overlay2]# docker info |grep storage 
WARNING: API is accessible on http://0.0.0.0:2375 without encryption.
         Access to the remote API is equivalent to root access on the host. Refer
         to the 'Docker daemon attack surface' section in the documentation for
         more information: https://docs.docker.com/go/attack-surface/
[root@hmm overlay2]# docker info |grep vfs 
WARNING: API is accessible on http://0.0.0.0:2375 without encryption.
         Access to the remote API is equivalent to root access on the host. Refer
         to the 'Docker daemon attack surface' section in the documentation for
         more information: https://docs.docker.com/go/attack-surface/
 Storage Driver: vfs //更改成功
[root@hmm overlay2]#

docker存储驱动

[root@hmm ~]# docker volume --help

Usage:  docker volume COMMAND

Manage volumes

Commands:
  create      Create a volume
  inspect     Display detailed information on one or more volumes
  ls          List volumes
  prune       Remove unused local volumes
  rm          Remove one or more volumes

Run 'docker volume COMMAND --help' for more information on a command.
[root@hmm ~]# docker volume create --help

Usage:  docker volume create [OPTIONS] [VOLUME]  //不写名字就是匿名卷

Create a volume

Options:
  -d, --driver string   Specify volume driver name (default "local")
      --label list      Set metadata for a volume   //设置卷的源数据
  -o, --opt map         Set driver specific options (default map[]) //指定卷的大小,使用什么方式进行挂载,驱动等
  1. 创建一个普通卷
root@hmm ~]# docker volume ls
DRIVER    VOLUME NAME
[root@hmm ~]# docker volume create test-vol1
test-vol1
[root@hmm ~]# docker volume inspect test-vol1
[
    {
        "CreatedAt": "2024-04-24T00:42:49+08:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/test-vol1/_data",
        "Name": "test-vol1",
        "Options": null,
        "Scope": "local"
    }
]
[root@hmm ~]# 
[root@hmm ~]# cd /var/lib/docker/volumes/
[root@hmm volumes]# ls
backingFsBlockDev  metadata.db  test-vol1
[root@hmm volumes]# cd test-vol1/
[root@hmm test-vol1]# ls
_data
[root@hmm test-vol1]# cd _data/
[root@hmm _data]# ls
[root@hmm _data]# touch yun3_test
[root@hmm _data]# ls
yun3_test
  1. 创建一tmpfs卷
[root@hmm _data]# docker volume create --driver local --opt type=tmpfs --opt device=,uid=1000 teste-vol2
teste-vol2
[root@hmm _data]# docker volume inspect teste-vol2
[
    {
        "CreatedAt": "2024-04-24T01:00:21+08:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/teste-vol2/_data",
        "Name": "teste-vol2",
        "Options": {
            "device": "tmpfs",
            "o": "size=100m,uid=1000",
            "type": "tmpfs"
        },
        "Scope": "local"
    }
]
  1. 创建带元数据的卷
[root@hmm _data]# docker volume create --label class=yun3 \
> --label age=20 \
> test-vol3
test-vol3
[root@hmm _data]# docker volume inspect test-vol3
[
    {
        "CreatedAt": "2024-04-24T01:01:49+08:00",
        "Driver": "local",
        "Labels": {
            "age": "20",
            "class": "yun3"
        },
        "Mountpoint": "/var/lib/docker/volumes/test-vol3/_data",
        "Name": "test-vol3",
        "Options": null,
        "Scope": "local"
    }
]

查看卷

  • 普通查看
[root@hmm _data]# docker volume ls
DRIVER    VOLUME NAME
local     421a92d5fae8a818a2dfdae251f86d23d62b0a02d26134836d7140bbb63a7e76
local     73401cb13134c689095a345c85ad635862c5e16eac4ea3c1c9402f6a85b38bf6
local     test-vol1
local     test-vol3
local     teste-vol2
  • 简单筛选
[root@hmm _data]# docker volume ls -f label=age //筛选标签含age的卷
DRIVER    VOLUME NAME
local     test-vol3
[root@hmm _data]# docker volume ls -f name=vol
DRIVER    VOLUME NAME
local     test-vol1
local     test-vol3
local     teste-vol2
[root@hmm _data]# docker volume ls -f name=vo3
DRIVER    VOLUME NAME
[root@hmm _data]# docker volume ls -f name=3
DRIVER    VOLUME NAME
local     421a92d5fae8a818a2dfdae251f86d23d62b0a02d26134836d7140bbb63a7e76
local     73401cb13134c689095a345c85ad635862c5e16eac4ea3c1c9402f6a85b38bf6
local     test-vol3
  • 只显示名字
[root@hmm _data]# docker volume ls -q
421a92d5fae8a818a2dfdae251f86d23d62b0a02d26134836d7140bbb63a7e76
73401cb13134c689095a345c85ad635862c5e16eac4ea3c1c9402f6a85b38bf6
test-vol1
test-vol3
teste-vol2
[root@hmm _data]#
  • 普通格式化输出
[root@hmm _data]# docker volume ls --format "{{.Name}}***{{.Scope}}***{{.Mountpoint}}"
421a92d5fae8a818a2dfdae251f86d23d62b0a02d26134836d7140bbb63a7e76***local***/var/lib/docker/volumes/421a92d5fae8a818a2dfdae251f86d23d62b0a02d26134836d7140bbb63a7e76/_data
73401cb13134c689095a345c85ad635862c5e16eac4ea3c1c9402f6a85b38bf6***local***/var/lib/docker/volumes/73401cb13134c689095a345c85ad635862c5e16eac4ea3c1c9402f6a85b38bf6/_data
test-vol1***local***/var/lib/docker/volumes/test-vol1/_data
test-vol3***local***/var/lib/docker/volumes/test-vol3/_data
teste-vol2***local***/var/lib/docker/volumes/teste-vol2/_data
[root@hmm _data]# 
  • json格式 格式化输出
[root@hmm _data]# docker volume ls --format "{{json .Name}}***{{json .Scope}}***{{json .Mountpoint}}"
"421a92d5fae8a818a2dfdae251f86d23d62b0a02d26134836d7140bbb63a7e76"***"local"***"/var/lib/docker/volumes/421a92d5fae8a818a2dfdae251f86d23d62b0a02d26134836d7140bbb63a7e76/_data"
"73401cb13134c689095a345c85ad635862c5e16eac4ea3c1c9402f6a85b38bf6"***"local"***"/var/lib/docker/volumes/73401cb13134c689095a345c85ad635862c5e16eac4ea3c1c9402f6a85b38bf6/_data"
"test-vol1"***"local"***"/var/lib/docker/volumes/test-vol1/_data"
"test-vol3"***"local"***"/var/lib/docker/volumes/test-vol3/_data"
"teste-vol2"***"local"***"/var/lib/docker/volumes/teste-vol2/_data"
[root@hmm _data]# 

绑定挂载

tmpfs挂载

标签:管理,root,存储配置,data,hmm,test,docker,local
From: https://www.cnblogs.com/humlogs/p/18140722

相关文章

  • 联通为客户提供运营商级机房环境存放主机设备及运维管理
    中国联通主机托管服务是面向企业和个人客户的一项专业级数据中心服务。该服务致力于为客户提供一个安全、稳定、高效的运营商级机房环境,用于存放主机设备,并提供全方位的运维管理。服务内容机房环境提供:提供专业级的运营商机房,确保设备运行环境的安全与稳定。机房采用先进的......
  • Linux服务器中Docker部署的GitLab镜像访问出现500错误
    一背景这几天发现在Linux服务器中Docker部署的GitLab镜像访问出现500错误,在重启服务器后大概10分钟再次出现该情况,后面登录服务器一步步排查最终解决问题,现在将解决问题的过程做一个总结。二过程分析首先第一步就是看看我们Docker目录下文件占用的情况,因为我们的Linux服务......
  • docker 镜像和容器的基本命令
    1.基本镜像命令(1)搜索镜像仓库dockersearchmysqldockersearchmysql:5.7(2)拉取镜像dockerpullmysql dockerpullmysql:5.7(3)查看镜像 dockerimages dockerimage(4)删除镜像dockerrmi镜像ID dockerrmi-f镜像ID(强制删除) 2.基本容......
  • 欧拉系统-安装Docker
    欧拉系统-安装Docker[toc]零、资料https://lab.huaweicloud.com/experiment-detail_2417?ticket=ST-92642093-vahMts7MDOKnplPdCsCFfCrs-sso一、步骤wgethttps://download.docker.com/linux/static/stable/x86_64/docker-18.09.9.tgztarzxfdocker-18.09.9.tgzmvd......
  • 甘特图是什么?利用甘特图来优化项目管理流程
     甘特图是项目管理软件中十分常见的功能,可以说每一个项目经理都要学会使用甘特图才能更好的交付项目。什么是甘特图?甘特图用来做什么?简单来说一种将项目任务与时间关系直观表示的图表,直观地展示了任务进度和持续时间。图片来源zz-plan甘特图一、甘特图的定义和特点1.定义......
  • 什么样的供应商管理方案,可以提高供应链的效率和可靠性?
    供应商管理方案是一套系统化的流程和策略,旨在规范供应商的选择、评估、合作和持续改进,以确保供应商能够满足企业在质量、交货、价格、服务等方面的要求。通过定期对供应商进行评鉴,包括品质、交期、价格、服务等项目,并进行季度总评,根据得分将供应商分为A、B、C、D等级;对于品质不良......
  • docker - [07] 部署ES+Kibana
    思考问题:以后在Tomcat部署项目,如果每次都要进入容器会十分麻烦,是否可以在容器外部提供一个映射路径,webapps,在外部放置项目,自动同步到容器内部? 一、启动esdockerrun-d--nameelasticsearch-p9200:9200-p9300:9300-e"discovery.type=single-node"elasticsearch:7.6.......
  • 如何将Docker中GitLab数据备份到宿主Linux上
    一宿主机准备存放备份文件的目录建议以年月日进行命名使用putty.exe或者PowerShell登录远程服务器cdshare(如果没有当前目录请创建该共享目录)mkdir20220930(在共享目录下创建备份文件夹)二进入Docker容器内部备份数据1.执行命令sudodockerexec-itgitlab/bin/......
  • docker compose 部署MetaBase,非常好用的BI工具
    docker-compose部署MetabaseMetabase官网:MetaBase部署步骤docker-compose文件准备docker-compose.ymlversion:'3.9'services:metabase:image:metabase/metabase:latestcontainer_name:metabasehostname:metabasevolumes:-/dev/ur......
  • docker虚拟化(一)
    常见的虚拟化有两种:kvm虚拟化和docker容器虚拟化kvm和vmware是类似的,kvm用于linux平台,vmware用于windows平台kvm叫做硬件级服务器虚拟化,虚拟物理服务器的。kvm虚拟化的隔离级别是硬件级的,遵循完整的网络协议和三次握手规则kvm优点:安全性高     缺点:启动时间和真实的操作......