docker镜像中文件丢失
背景介绍
笔者创建了一个镜像,然后在不同的主机上启动,发现有的能启动,有的却不行,报错信息为找不到文件。
犹记得当初有人介绍,只要docker镜像做好了,拿到任何地方都可以用,此处好像不成呢,好诡异的事。
初步怀疑docker存储驱动导致的问题。
制作镜像步骤还原
1、在某一台主机做dockerfile,该主机环境如下
[root@ ~]# docker info
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 46
Server Version: 1.13.1
Storage Driver: btrfs
Build Version: Btrfs v4.9.1
Library Version: 102
Logging Driver: journald
Cgroup Driver: systemd
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: /usr/libexec/docker/docker-init-current
containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: 9c3c5f853ebf0ffac0d087e94daef462133b69c7 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
seccomp
WARNING: You're not using the default seccomp profile
Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.0-514.16.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 40
Total Memory: 125.7 GiB
Name: cndh1325-10-12.ptmind.com
ID: 2AHA:F2JK:ECEX:U2WY:OAET:BFOS:CY77:MNAK:2Y2P:7DRS:KU72:6VI5
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Registries: docker.io (secure)
[root@test ~]# xfs_info /
meta-data=/dev/sda5 isize=256 agcount=4, agsize=116621952 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=466487808, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=227777, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
可以看到,制作镜像的主机存储驱动为 Storage Driver: btrfs ,文件系统xfs不支持d_type。
将镜像上传镜像库,已提供使用。
2、在A主机拉取镜像,镜像不能启动
笔者是创建的elasticsearch:6.2.4版本镜像,从官方拉取,官方镜像默认包含ingest-geoip插件,在dockerfile中已经将插件删除
dockfile如下
FROM docker.elastic.co/elasticsearch/elasticsearch:6.2.4 COPY elasticsearch.yml /usr/share/elasticsearch/config/
COPY jvm.options /usr/share/elasticsearch/config/ RUN /usr/share/elasticsearch/bin/elasticsearch-plugin remove ingest-geoip --purge \
&& /usr/share/elasticsearch/bin/elasticsearch-plugin remove ingest-user-agent \
&& chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/config \
报错信息如下:
Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config/ingest-geoip
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config/ingest-geoip
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
A主机环境如下
[root@A ~]# docker info
Containers: 20
Running: 20
Paused: 0
Stopped: 0
Images: 21
Server Version: 1.13.1
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: false
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: systemd
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: /usr/libexec/docker/docker-init-current
containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: 5eda6f6fd0c2884c2c8e78a6e7119e8d0ecedb77 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
seccomp
WARNING: You're not using the default seccomp profile
Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.0-862.9.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 16
Total Memory: 62.74 GiB
Name: jp33e505-10-14.ptengine.com
ID: PDSY:4YPU:AUSW:HA4V:223D:YBSG:E67E:TUJF:3WUJ:EL7J:VNGH:LG3O
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Registries: docker.io (secure)
[root@A ~]# xfs_info /
meta-data=/dev/sdc2 isize=256 agcount=4, agsize=6553600 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=26214400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=12800, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
检查发现存储驱动为overlay2,文件系统xfs不支持d_type。
3、在B主机拉取镜像,镜像能启动
B主机环境如下
[root@B ~]# docker info
Containers: 21
Running: 21
Paused: 0
Stopped: 0
Images: 22
Server Version: 1.13.1
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: systemd
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: /usr/libexec/docker/docker-init-current
containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: df5c38a9167e87f53a9894d77c0950e178a745e7 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
seccomp
WARNING: You're not using the default seccomp profile
Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.0-957.10.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 16
Total Memory: 62.75 GiB
Name: jp33e506-10-19.ptengine.com
ID: OFVX:ELT3:RNT4:OM6W:L7GC:OC47:R5QJ:XBVL:T5HW:UGIL:PJUJ:66ZO
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Registries: docker.io (secure)
[root@B ~]# xfs_info /
meta-data=/dev/md126p3 isize=512 agcount=4, agsize=7169408 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=28677632, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=14002, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
现在已经很明显了,A和B唯一不同的就是文件系统xfs是否支持d_type,而官方已明确说明如果使用xfs文件系统,需要d_type的支持,即 ftype=1,具体参考 https://docs.docker.com/storage/storagedriver/overlayfs-driver/
修改A主机的d_type
mkfs.xfs -f -n ftype=1 /dev/sdg5
重启docker,一切正常。
docker镜像中文件丢失的更多相关文章
- 在docker镜像中加入环境变量
原文链接 前言 reference:https://vsupalov.com/docker-build-time-env-values/ 很多时候,我们需要在docker镜像中加入环境变量,本人了解的 ...
- 怎样修复“Windows/System32/Config/System中文件丢失或损坏”故障
怎样修复“Windows/System32/Config/System中文件丢失或损坏”故障 英文原文引自 http://xphelpandsupport.mvps.org/how_do_i_repa ...
- Docker镜像构建文件Dockerfile及相关命令介绍
使用docker build命令或使用Docker Hub的自动构建功能构建Docker镜像时,都需要一个Dockerfile文件.Dockerfile文件是一个由一系列构建指令组成的文本文件,doc ...
- 向docker镜像中传递变量的两种方式
测试用到的python文件: #!/usr/bin/env python3 #conding: utf-8 from http.server import HTTPServer, BaseHTTPRe ...
- 菜鸟系列docker——docker镜像中(4)
docker镜像命令 该章节主要介绍docker image相关命令实践操作,建议都一起跑一边 1. docker images 列举本机docker镜像 [centos@jiliguo docker ...
- Docker镜像中的base镜像理解
base 镜像有两层含义: 不依赖其他镜像,从 scratch 构建. 其他镜像可以之为基础进行扩展. 所以,能称作 base 镜像的通常都是各种 Linux 发行版的 Docker 镜像,比如 Ub ...
- (转)Docker镜像中的base镜像理解
base 镜像有两层含义: 不依赖其他镜像,从 scratch 构建. 其他镜像可以之为基础进行扩展. 所以,能称作 base 镜像的通常都是各种 Linux 发行版的 Docker 镜像,比如 Ub ...
- docker 镜像中包含数据库环境和运行环境
需求: 一个镜像中要包含数据库环境和运行环境 Apache 环境 + mariadb 已经在拉取了Apache的运行环境 - 拉取代码 git https://github.com/timhaak/d ...
- docker容器中文件的上传与下载
原文地址:传送门 1.上传文件 docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH [OPTIONS]:保持源目标中的链接,例: docker cp ...
随机推荐
- 【LeetCode】986. Interval List Intersections 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 日期 题目地址:https://leetco ...
- hbase构建二级索引解决方案
关注公众号:大数据技术派,回复"资料",领取1024G资料. 1 为什么需要二级索引 HBase的一级索引就是rowkey,我们仅仅能通过rowkey进行检索.假设我们相对Hbas ...
- Java中PO、DO、DTO、 VO、 BO、POJO 、DAO、TO的概念
1. PO(persistant object) 持久对象 在 O/R 映射的时候出现的概念,如果没有 O/R 映射,没有这个概念存在了. 通常对应数据模型 ( 数据库 ), 本身还有部分业务逻辑的 ...
- 基于 Electron 的 Rubick 2.4k star 啦,同步更新新功能!
为什么要做 Rubick 其实做 Rubick 1.x 的初衷就是解决自己的问题的:特别需要一款支持自定义插件的桌面端应用来简化使用者安装庞大桌面端应用的臃肿.而且涉及到数据安全的问题,插件只能在公司 ...
- WPF之AvalonEdit实现MVVM双向绑定
AvalonEdit简介 AvalonEdit是基于WPF开发的代码显示控件,默认支持多种不同语言的关键词高亮,并且可以自定义高亮配置.所以通过AvalonEdit可以快速开发出自己想要的代码编辑器. ...
- BL8810|USB2.0高速闪存读卡器芯片|BL8810规格书
1.说明 BL8810是一款USB 2.0读卡器控制器,采用高度集成的单芯片解决方案,旨在提供USB2.0和SD.SDHC.mini SD.Micro SD(T-Flash)接口规范之间的高速数据传输 ...
- Linux压缩和解压类
gzip/gunzip gzip 文件:压缩文件为.gz gunzip 文件:解压文件 注: 1. 只能压缩和解压文件 2. 只是将hello.txt压缩成hello.txt.gz,并没有改变存储位置 ...
- 编写Java程序,用户在网上购买商品(good),当用户买了一本书(book)、一顶帽子(hat)或者买了一双鞋子(shoe),卖家就会通过物流将商品邮寄给用户,使用简单工厂模式模拟这一过程。
查看本章节 查看作业目录 需求说明: 编写Java程序,用户在网上购买商品(good),当用户买了一本书(book).一顶帽子(hat)或者买了一双鞋子(shoe),卖家就会通过物流将商品邮寄给用户, ...
- LCA/在线(倍增)离线(Tarjan)
概念 祖先 公共祖先 最近公共祖先 方法1:暴力爬山法 方法2:倍增 求公共祖先 求俩点的距离 Tarjan 概念 祖先 有根树中,一个节点到根的路径上的所有节点被视为这个点的祖先,包括根和它本身 公 ...
- 如何用微信小程序,每天给自己赚个鸡腿?
假期如果实在无聊的话,那跟随田同学的脚步上架一个小程序吧. 话说:谁不想拥有一个自己的小程序呢?既可以赚点小钱又可以长长见识. 不懂小程序的小白能不能做出来呢?那来对了,这个教程就是针对小白的. 今天 ...