docker study --- overlay docker cp not work

本文记录了一次Docker环境中遇到的“dockercp”命令无法正常工作的问题。该问题表现为从容器复制文件到宿主机时找不到文件。通过检查Docker的overlay文件系统发现,文件存在于upper目录而非merged目录中,这导致了文件复制失败。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近公司有人开出个ticket 给Docker team。我看了看。


背景:

We meet another issue on Fawn’s lab -- “docker cp” doesn’t work. Could you please help to have a check?
 
It had worked well last week. But now, it show following error:
[root@utas1mvmft3-http-node-0 ~]# docker cp c8ee965ce671:/root/hss-sim .
Error response from daemon: lstat /var/lib/docker/overlay/a884c04d7108c7400738f677eaeca348414a57f59f92e0fc368282587800fe1a/merged/root/hss-sim: no such file or directory
 
Following is /root dir in this container:
root @ sim : ~
> pwd
/root
root @ sim : ~
> ls
dtd-client  dtd-client-lesley  dtd-client.off  dtd-client.tar.gz.max.127.ro.connections  dtd-sims-libs  hss  hss-sim  qos-sim
 
But in the dir of the overlay subdir:
[root@utas1mvmft3-http-node-0 ~]# ls /var/lib/docker/overlay/a884c04d7108c7400738f677eaeca348414a57f59f92e0fc368282587800fe1a/merged/root/
diamMultiClientSim  diamMultiClientSim.MessagesToDTD  diamMultiClientSim.prov  dtd-client-lesley  rf.prov  ro.prov  run_dtd-client.bash  sh.prov
 
Then I find hss-sim in the “upper” subdir:
[root@utas1mvmft3-http-node-0 ~]# ls /var/lib/docker/overlay/a884c04d7108c7400738f677eaeca348414a57f59f92e0fc368282587800fe1a/upper/root/
dtd-client  dtd-client-lesley  hss  hss-sim  qos-sim
 
But the contents are still not same between this dir and the container, although Fawn finds what she needs.
In the “upper” dir:
[root@utas1mvmft3-http-node-0 ~]# ls /var/lib/docker/overlay/a884c04d7108c7400738f677eaeca348414a57f59f92e0fc368282587800fe1a/upper/root/hss-sim/
as_entity  hss.cfg  hss.cfg.new  hss.log  hsssh  qos.log
 
In the container:
root @ sim : ~
> ls hss-sim/
as_entity  hss.cfg  hss.cfg.new  hss.log  hss_simulator  hsssh  qos.log  repository_data  subscriber_data
 

这个issue起因是一个同事问我docker cp不work。 当时着急测试。我知道肯定是docker mount哪里出现了问题。为了让她尽快测试。 我告诉她把数据拷贝到》

/var/lib/docker/overlay/a884c04d7108c7400738f677eaeca348414a57f59f92e0fc368282587800fe1a/upper 这个目录就能用了。然后也没仔细研究这个问题。 这个问题也不能reproduce。

按理来说。 upper这个目录是docker 的rw曾, docker的操作也是操作这个层。

The "upper" directory is the containers read-write layer. Any changes made to 
the container are written to this directory.

merge这个目录应该显示read only 和rw层所有信息。

The "merged" directory is effectively the containers mount point. This is where
 the unified view of the image ("lowerdir") and container ("upperdir") is 
exposed. Any changes written to the container are immediately reflected in this
 directory.

测试往upper dir写数据, 不会在merger dir出现。 也就是说“unified view”失效了。

等有时间继续研究




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值