[root@docker001 ~]# docker info
Client: Docker Engine - Community
Version: 26.1.4
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.14.1
Path: /usr/libexec/docker/cli
plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.27.1
Path: /usr/libexec/docker/cli
plugins/docker-composeServer:
Containers: 2 #容器数量
Running: 2 #正在运⾏的容器
Paused: 0
Stopped: 0
Images: 3
Server Version: 26.1.4
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:
d2d58213f83a351ca8f528a95fbd145f5654e957
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: builtin
Kernel Version: 3.10.0-1160.119.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 972.1MiB
Name: docker001.yuanyu.zhangmin
ID: 7684bd62-67f2-48c8-a2ee-daaa649abf70
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://do.nark.eu.org/
https://dc.j8.work/
https://docker.m.daocloud.io/
https://dockerproxy.com/
https://docker.mirrors.ustc.edu.cn/ https://docker.nju.edu.cn/
Live Restore Enabled: false
[DEPRECATION NOTICE]: 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/
In future versions this will be a hard failure
preventing the daemon from starting! Learn more
at: https://docs.docker.com/go/api-security/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
[root@docker001 ~]# ls /var/lib/docker/buildkit containers engine-id image network
overlay2 plugins runtimes swarm tmp volumes
[root@docker001 ~]# tree -L 2 /var/lib/docker/
/var/lib/docker/
"## buildkit
$ "## cache.db
$ "## containerdmeta.db
$ "## content
$ "## executor
$ "## history.db
$ "## metadata_v2.db
$ "## net
$ %## snapshots.db
"## containers
$ "##
5ce068ef110b103c565602dcc7c4af66f91cd2b6ea8129af7a
be5383c4aa0f8d
$ %##
948f20e1ed4758e78759de8f9ce9b34a7f44c431bc8ead75b6
70e1a5b488654c
"## engine-id
"## image
$ %## overlay2
"## network
$ %## files
"## overlay2$ "##
0471ada2dce770506dd29557cd04ce8ee3f4a632a81f482ce0
e2b139d8251611
$ "##
109e3f2004911eabcd6934be32281c1ed9897b46de48a8960d
1253a668145126
$ "##
117fd8ba9ff0ed91d48cff774a1061baf9efe6fe4d63cdb14e
768bfd742a3f3b
$ "## 235zotit1cskmcglyr9nykhou
$ "## 2q24gwawlr1jvee48x9zrqxai
$ "##
332fbcc4b5175a6970ca7788db3898f9102f84f6a68029f57f
ccfbe2a3408729
$ "##
332fbcc4b5175a6970ca7788db3898f9102f84f6a68029f57f
ccfbe2a3408729-init
$ "## 3y08ei53ildl077di6t0xhvt4
$ "##
4e699a81c9752aa0e2182cb302c11af1f39093ee81f2c7cf1a
9ef7189feee839
$ "##
4e699a81c9752aa0e2182cb302c11af1f39093ee81f2c7cf1a
9ef7189feee839-init$ "##
561bbad3be962475eff729aa3d5240eb213176bae772cfe4e5
d45f22b123fb7a
$ "##
561bbad3be962475eff729aa3d5240eb213176bae772cfe4e5
d45f22b123fb7a-init
$ "##
56b9d2c60d83b8e72cd15975c63ebfbdd3e6055d49b3d739d7
5a1ff94e277dda
$ "##
6564c73ad543b723881b076fe387422b191cd48158811ce89b
aaa6406b284df4
$ "##
7711d9a14b6fc142ef00c96d7d9140628b60d01f00f253e584
80e4088b5434a4
$ "##
7a9653ab64da80a7fd2ffdb6cbac391b298c9df892db50d053
9f35682379023c
$ "##
8703d4e4fb30097919c7e5983aec21c548b188a3a4bee865dd
5043b948fe5c2d
$ "##
89bb8ec84e2069acba669fecb7ef2500a054652586c80e2e94
7173b5b369a834$ "##
a0f5901965932b6db0ec37cd31654532e08cac14e0b12b1897
090cdef1ed9a3d
$ "##
a0f5901965932b6db0ec37cd31654532e08cac14e0b12b1897
090cdef1ed9a3d-init
$ "##
a63d730255cb91be82e6c51cc677717728b45f4032e4e5e48b
0e2a9e5aa2deab
$ "##
a63d730255cb91be82e6c51cc677717728b45f4032e4e5e48b
0e2a9e5aa2deab-init
$ "## ah3i2ooqroom29dxbl7tfn7qq
$ "## backingFsBlockDev
$ "##
c8ee533075c8244596da864a555935839a9850b450b6687201
80802707a9a146
$ "##
c8ee533075c8244596da864a555935839a9850b450b6687201
80802707a9a146-init
$ "##
cca21d9c366100f059609ce466a8ffdd5e820407d89c1e89b2
154e0573b04b67
$ "##
e2bc5e84f80761a20c10b0d7a914141e912f63ed79266ef381
290c424bf40b1d$ "## el3ttxid0yg954kt85y798vze
$ "##
f77539952d704ff61e8983dd2db9e7998503d1e98ad3df4db9
bed32a7fd50903
$ "## gf94ym4xk3ow1tk39dihylvyd
$ "## hp0h9kwz0lhzvp1vitb7luhy3
$ "## kfjteefzg4mrc7959nj2au3le
$ "## kkg0d8n5rg51yksgbm2xxw8ou
$ "## l
$ "## mwd5hxe90l7liljg8pkaam3r6
$ "## nbxfcewpnxawtj825cu3xw3ph
$ "## ngvvz7u0xe1xgs82c1h0qspcm
$ "## on9ypo393wf86a8b1kuawmsez
$ "## pc9zeyl68k1ju2xvdiuv5sihd
$ "## phy7f7a1llvm8rsn7auwsj6iw
$ "## pi9f4xmuk60u70onzmz1q4r9c
$ "## pqyc1rcou6ddvbnygkrs68c3l
$ "## q09bzwofod6zhhhpttb9tpmbz
$ "## qazjj8ki0z9q206jga0sii0ru
$ "## sroxs9tw339wyo94pwle3llym
$ "## w09y9n8pqbfexzhk4ut61ktma
$ "## whbqjbm3dp1wrxtblscir4ywr
$ %## z5yoracg29fmorw6e99o4qshv
"## plugins
$ "## storage
$ %## tmp"## runtimes
"## swarm
"## tmp
%## volumes
"##
1652bd379334d5a944d0b40dde7b0fe944e3c043dc850ec171
8ccc9f52e31872
"## backingFsBlockDev
"##
c2dbff511839eeb4a788c15fc2414b826b89222555d27070ea
65467cb1ac26e1
%## metadata.db
69 directories, 9 files查看系统内核
[root@docker001 l]# uname -r
3.10.0-1160.119.1.el7.x86_64
查看⽂件系统
[root@docker001 l]# df -i
⽂件系统 Inode 已⽤(I) 可⽤(I) 已⽤
(I)% 挂载点
devtmpfs 121445 390 121055
1% /dev
tmpfs 124432 1 124431
1% /dev/shmtmpfs 124432 794 123638
1% /run
tmpfs 124432 16 124416
1% /sys/fs/cgroup
/dev/mapper/centos-root 8910848 101057 8809791
2% /
/dev/sda1 524288 333 523955
1% /boot
tmpfs 124432 1 124431
1% /run/user/0
overlay 8910848 101057 8809791
2%
/var/lib/docker/overlay2/a0f5901965932b6db0ec37cd3
1654532e08cac14e0b12b1897090cdef1ed9a3d/merged
overlay 8910848 101057 8809791
2%
/var/lib/docker/overlay2/c8ee533075c8244596da864a5
55935839a9850b450b668720180802707a9a146/merged
新建⼀个⽂件之后 可⽤的节点减少⼀个
[root@docker001 ~]# touch 123.txt
[root@docker001 ~]# df -i
⽂件系统 Inode 已⽤(I) 可⽤(I) 已⽤
(I)% 挂载点devtmpfs 121445 390 121055
1% /dev
tmpfs 124432 1 124431
1% /dev/shm
tmpfs 124432 794 123638
1% /run
tmpfs 124432 16 124416
1% /sys/fs/cgroup
/dev/mapper/centos-root 8910848 101058 8809790
2% /
/dev/sda1 524288 333 523955
1% /boot
tmpfs 124432 1 124431
1% /run/user/0
overlay 8910848 101058 8809790
2%
/var/lib/docker/overlay2/a0f5901965932b6db0ec37cd3
1654532e08cac14e0b12b1897090cdef1ed9a3d/merged
overlay 8910848 101058 8809790
2%
/var/lib/docker/overlay2/c8ee533075c8244596da864a5
55935839a9850b450b668720180802707a9a146/merged
创建软连接之后,节点减少⼀个[root@docker001 ~]# ln -s 123.txt 123.lk
[root@docker001 ~]# df -i
⽂件系统 Inode 已⽤(I) 可⽤(I) 已⽤
(I)% 挂载点
devtmpfs 121445 390 121055
1% /dev
tmpfs 124432 1 124431
1% /dev/shm
tmpfs 124432 794 123638
1% /run
tmpfs 124432 16 124416
1% /sys/fs/cgroup
/dev/mapper/centos-root 8910848 101059 8809789
2% /
/dev/sda1 524288 333 523955
1% /boot
tmpfs 124432 1 124431
1% /run/user/0
overlay 8910848 101059 8809789
2%
/var/lib/docker/overlay2/a0f5901965932b6db0ec37cd3
1654532e08cac14e0b12b1897090cdef1ed9a3d/merged
overlay 8910848 101059 8809789
2%
/var/lib/docker/overlay2/c8ee533075c8244596da864a5
55935839a9850b450b668720180802707a9a146/merged在启动docker服务后会新建/var/lib/docker
[root@docker001 ~]# ls /var/lib/docker
ls: ⽆法访问/var/lib/docker: 没有那个⽂件或⽬录
[root@docker001 ~]# systemctl start docker.service
[root@docker001 ~]# ls /var/lib/docker
buildkit containers engine-id image network
overlay2 plugins runtimes swarm tmp volumes
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDev l
拉取⼀个新镜像之后,就会在overlay2⽂件夹中保存新的⽂件[root@docker001 ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos
a1d0c7532777: Pull complete
Digest:
sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534b
bdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDev
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34 l
[root@docker001 ~]#
查看⽂件保存位置[root@docker001 ~]# cd
/var/lib/docker/overlay2/ce54a04e45edb448429f2f7ad
b8a8a1d23379e300f8e7c1a98beb4512d932c34/
[root@docker001
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34]# ls
diff link
[root@docker001
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34]# ls diff/
bin etc lib lost+found mnt proc run srv
tmp var
dev home lib64 media opt root sbin sys
usr
[root@docker001
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34]#
创建容器后出现2个新的⽂件夹[root@docker001 ~]# docker run -it --name c0
centos:latest /bin/bash
[root@4c7f96d1a03e /]# [root@docker001 ~]#
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDev
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb-init
查看容器⽬录[root@docker001 ~]# cd
/var/lib/docker/overlay2/e291e027242e013f682fe631b
83e89a90f9ba68fa1af92fda2fe4d9094f7b7eb
[root@docker001
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb]# ls
diff link lower merged work
[root@docker001
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb]# cat lower
l/LBSEYI2LHNHNIYE7AYQMOC6RBP:l/KQTNFI7JQXIRWB3PFKE
D2HRWJD[root@docker001
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb]# ls merged/
bin etc lib lost+found mnt proc run srv
tmp var
dev home lib64 media opt root sbin sys
usr
[root@docker001
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb]#
在外⾯使⽤exec创建⼀个⽂件[root@docker001 ~]# docker exec 4c7f dd
if=/dev/zero of=/test bs=10M count=100
100+0 records in
100+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 2.7744
s, 378 MB/s
[root@docker001 ~]# ls
/var/lib/docker/overlay2/e291e027242e013f682fe631b
83e89a90f9ba68fa1af92fda2fe4d9094f7b7eb/merged/
bin etc lib lost+found mnt proc run srv
test usr
dev home lib64 media opt root sbin sys
tmp var
容器保存镜像和数据
查看容器挂载
容器被移除以后,这个⽂件就会被删除,stop不会删除
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDevce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb-init
l
[root@docker001 ~]# docker stop c0
c0
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDev
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb-init
l
[root@docker001 ~]# docker rm c0
c0
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDev
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34 l
[root@docker001 ~]#
创建私有仓库,在企业中分享项⽬
# 安装仓库镜像
[root@docker001 ~]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
930bdd4d222e: Pull complete
a15309931e05: Pull complete
6263fb9c821f: Pull complete
86c1d3af3872: Pull complete
a37b1bf6a96f: Pull complete
Digest:
sha256:12120425f07de11a1b899e418d4b0ea174c8d4d572d
45bdb640f93bc7ca06a3d
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest
#查看新安装的镜像
[root@docker001 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
registry latest cfb4d9904335 10 months
ago 25.4MB
centos latest 5d0da3dc9764 2 years ago
231MB# 创建挂载的⽬录
[root@docker001 ~]# mkdir /opt/dockeregistry
# 创建容器,映射端⼝,挂载⽂件
[root@docker001 ~]# docker run -d --name c1 -
p5000:5000 -v
/opt/dockeregistry/:/var/lib/registry
registry:latest
7ec28de22490aee02bd542ef22076f8ba746f7513cf96bf501
d817bc07b38f27
[root@docker001 ~]# docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
7ec28de22490 registry:latest "/entrypoint.sh
/etc…" 13 seconds ago Up 12 seconds
0.0.0.0:5000->5000/tcp, :::5000->5000/tcp c1
# 访问⽬录⻚
[root@docker001 ~]# curl
http://10.1.1.50:5000/v2/_catalog
{"repositories":[]}
# 创建仓库[root@docker001 ~]# vim /etc/docker/daemon.json
[root@docker001 ~]# cat /etc/docker/daemon.json
{
"insecure-registries":[
"http://10.1.1.50:5000"
],
"registry-mirrors": [
"https://do.nark.eu.org",
"https://dc.j8.work",
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"
],
"hosts": [
"tcp://0.0.0.0:2375",
"unix:///var/run/docker.sock"
]
}
# 重启docker服务[root@docker001 ~]# systemctl restart
docker.service
# 查看镜像
[root@docker001 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
registry latest cfb4d9904335 10 months
ago 25.4MB
centos latest 5d0da3dc9764 2 years ago
231MB
# 为要上传的镜像添加标记
[root@docker001 ~]# docker tag centos:latest
10.1.1.50:5000/centos:v0
[root@docker001 ~]# docker images
REPOSITORY TAG IMAGE ID
CREATED SIZE
registry latest cfb4d9904335
10 months ago 25.4MB
10.1.1.50:5000/centos v0 5d0da3dc9764 2
years ago 231MB
centos latest 5d0da3dc9764 2
years ago 231MB10.1.1.50/centos v0 5d0da3dc9764 2
years ago 231MB
[root@docker001 ~]# docker push
10.1.1.50:5000/centos:v0
The push refers to repository
[10.1.1.50:5000/centos]
Get "http://10.1.1.50:5000/v2/": dial tcp
10.1.1.50:5000: connect: connection refused
[root@docker001 ~]# docker start c1
c1
[root@docker001 ~]# docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
7ec28de22490 registry:latest "/entrypoint.sh
/etc…" 16 minutes ago Up 4 seconds
0.0.0.0:5000->5000/tcp, :::5000->5000/tcp c1
[root@docker001 ~]# docker push
10.1.1.50:5000/centos:v0
The push refers to repository
[10.1.1.50:5000/centos]
74ddd0ec08fa: Pushed
v0: digest:
sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c8386
3037fa3aab063a7fdb9dc size: 529
[root@docker001 ~]# ls /opt/1.png assets dist
index.html
2.png containerd dockeregistry
nohup.out
application.properties cvloume favicon.ico
Project_ExamSystem-V1.0.0.war
[root@docker001 ~]# ls /opt/dockeregistry/
docker
[root@docker001 ~]# ls /opt/dockeregistry/docker/
registry
[root@docker001 ~]# ls
/opt/dockeregistry/docker/registry/
v2
[root@docker001 ~]# ls
/opt/dockeregistry/docker/registry/v2/
blobs repositories
[root@docker001 ~]# ls
/opt/dockeregistry/docker/registry/v2/repositories
/
centos
[root@docker001 ~]#1.拉取registry
docker pull registry
2.创建挂载⽬录
mkdir /regist
3.启动容器,映射端⼝,挂载⽬录
docker run -d --name c0 -v
/regist/:/var/lib/rigistry/ -p5000:5000
registry:latest
4.访问仓库
curl http://192.168.71.50:5000/v2/_catelog
5.配置pull和push,修改daemon.jsonvim /etc/docker/daemon.json
{
.....,
"insecure-registries":[
"http://192.168.71.50:5000"
]
}
:wq
6.修改了配置⽂件,重启docker服务
systemctl restart docker
7.启动registry容器
docker start r1
curl localhost:5000/v2/_catalog