Ubuntu 16.04python
Dockerversion 1.12.6, build 78d1802docker
從官方庫pull一個鏡像:docker pull ubuntu:14.04json
1、在image文件夾中尋找ubuntu
1.找到鏡像庫的文件ui
首先看repositories.json中的數據.net
root@ubuntu:/var/lib/docker#cat /var/lib/docker/image/aufs/repositories.json | python -mjson.tool3d
{get
"Repositories": {ubuntu16.04
"ubuntu": {it
"ubuntu:14.04":"sha256:4a2820e686c449bc943eab8492df4b4eb7f7e8fabda5258d7bc551fec5790436",
"ubuntu@sha256:5faf6cb681da2be979a177b60d8c18497f962e3d82268c49db6c74008d0c294d":"sha256:4a2820e686c449bc943eab8492df4b4eb7f7e8fabda5258d7bc551fec5790436"
}
}
}
看看,是否是正好和docker images的內容一致呢
root@ubuntu:/var/lib/docker#docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 14.04 4a2820e686c4 3 weeks ago 188 MB
2.找到鏡像描述文件
/var/lib/docker/image/aufs/imagedb/content/sha256/4a2820e686c449bc943eab8492df4b4eb7f7e8fabda5258d7bc551fec5790436
是一個json文件咱們只截取了部分:
"rootfs":{
"type": "layers",
"diff_ids": [
"sha256:9669d6b7338336d92ca8e8e5bb90a4a35a934d1c94017322bef35a838615b4ea",
"sha256:f5cfc06b640d49f4e5b0778531394ed4819d8824c46cbc21481f5531db35d970",
"sha256:768dcfe5d05fd2355facaacaf64a45e84ac4c6b895f335ee02f322a35e912d80",
"sha256:d0757a6730d0f8242d131bdb86df046fbd5eb6e3a04328aa10e8881166101a94",
"sha256:d649a240e4537a905c43c0f9fd7bfa3f3cbe693b963e838eb6e84065b57aae3d"
]
}
3.找到鏡像文件的layerdb
root@ubuntu:/var/lib/docker#ls /var/lib/docker/image/aufs/layerdb/sha256
76f1e34d1d2f369222db0aababcfe88a86e7773289ee479aa8a37db2dbc1ae78
7bb5a611d10e491eda648224aeb1466d7e7c99b4dc73c30acf01f303159e7405
9669d6b7338336d92ca8e8e5bb90a4a35a934d1c94017322bef35a838615b4ea
c872fbb3ed98d37a6abeebcfa16316bde7adafafabb8c7ff66a1ba53aa29f0bc
ddc772e5acb244ff1a1ddc32c6fbe5687b68c26090ce85e1855022ac6afcefbc
查看文件夾中文件
root@ubuntu:/var/lib/docker#ls /var/lib/docker/image/aufs/layerdb/sha256/9669d6b7338336d92ca8e8e5bb90a4a35a934d1c94017322bef35a838615b4ea/
cache-id diff size tar-split.json.gz
查看cache-id中內容:
b1c8bba6bd247accbc8082a4c46aa129e2b6489bd9bffe08387e50b43a08e1cd
2、在aufs文件夾中尋找
cache-id中數據對應aufs/diff文件夾下一個文件
root@ubuntu:/var/lib/docker#ls /var/lib/docker/aufs/diff
045a5f72741ab97228e00f1c8bd7d67b682e12c30def9efec769188e1deb9a56
8444bf1d9f50bf52f649d6e27d94a1fad34e7022e1ae27396b02cafaeb4d37bc
b1c8bba6bd247accbc8082a4c46aa129e2b6489bd9bffe08387e50b43a08e1cd
caba5c4f6a8438d54f4045d06afe9d06ad6c44d7db5bf355d36a18c0fd29d5d3
d04b500544d2efcb8e7e5feb8d37c405360fc9807f272c93eb3fd8cd735a13c5
咱們看一下b1c8bba6bd247accbc8082a4c46aa129e2b6489bd9bffe08387e50b43a08e1cd中內容
root@ubuntu:/var/lib/docker#ls/var/lib/docker/aufs/diff/b1c8bba6bd247accbc8082a4c46aa129e2b6489bd9bffe08387e50b43a08e1cd/
bin dev home lib64 mnt proc run srv tmp var boot etc lib media opt root sbin sys usr
docker鏡像的存儲路徑爲/var/lib/docker/aufs/
上面的邏輯不嚴謹,僅僅記錄本身尋找daocker鏡像存儲的位置的過程。旨在尋找鏡像id和aufs文件夾下的鏡像文件之間的聯繫。
ubuntu16.04中的docker使用的是aufs文件系統,能夠經過了解aufs文件系統來了解鏡像描述文件和真正的鏡像存儲位置的關聯。