镜像基础
要使用docker镜像,首先我们要知道镜像是分层的,然后讲这些层通过联合挂载的方式挂载到一起,并且镜像是只读的。
首先我们来说第一个:镜像分层
[root@node7 ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
000eee12ec04: Pull complete
eb22865337de: Pull complete
bee5d581ef8b: Pull complete
Digest: sha256:50cf965a6e08ec5784009d0fccb380fc479826b6e0e65684d9879170a9df8566
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
以nginx镜像来说,我们在pull这个镜像的时候,可以很明显的看到他的镜像是分三层的,每层都是独立的,也就是说我们其实是pull了三层,这三层共同组成了一个nginx镜像,并且每层都有独立的唯一id,这个id是不重复的,如果后期我们使用的其他镜像也用到了这个层,那么就会直接拿来使用,不会再去pull。我们还可以看镜像的详细信息
[root@node7 ~]# docker inspect image nginx
[
{
"Id": "sha256:231d40e811cd970168fb0c4770f2161aa30b9ba6fe8e68527504df69643aa145",
"RepoTags": [
"nginx:latest"
],
"RepoDigests": [
"nginx@sha256:50cf965a6e08ec5784009d0fccb380fc479826b6e0e65684d9879170a9df8566"
],
"Parent": "",
"Comment": "",
"Created": "2019-11-23T01:12:31.219881158Z",
"Container": "806a0a78bcfee5212b2530e6f2a7e3f8eec5b51cc55d7a28935f5f8c8bd45826",
"ContainerConfig": {
"Hostname": "806a0a78bcfe",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NGINX_VERSION=1.17.6",
"NJS_VERSION=0.3.7",
"PKG_RELEASE=1~buster"
],