Docker【安装与基本使用】

【1】Docker的安装

注意:如果之前安装过docker其他版本,请删除干净。

docker-01

10.0.0.51

2G

docker-02

10.0.0.52

2G

 docker-01

[root@docker-01 ~]# cp -rp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 
cp: overwrite ‘/etc/localtime’? y[root@docker-01 ~]# ntpdate ntp1.aliyun.com[root@docker-01 ~]# hwclock --systohc[root@docker-01 ~]# vim /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

[root@docker-01 ~]#  wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
--2023-07-17 21:26:12--  http://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.15.130, 2402:f000:1:400::2
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.15.130|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1919 (1.9K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/docker-ce.repo’100%[=========================================================>] 1,919       --.-K/s   in 0s      2023-07-17 21:26:12 (10.2 MB/s) - ‘/etc/yum.repos.d/docker-ce.repo’ saved [1919/1919][root@docker-01 ~]# sed -i 's+donload.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo[root@docker-01 ~]# yum -y install docker-ce[root@docker-01 ~]# mkdir docker-ce
[root@docker-01 ~]# find /var/cache/yum/x86_64/7/ -type f -name "*.rpm" | xargs mv -t docker-ce/[root@docker-01 ~]# docker version 
Client: Docker Engine - CommunityVersion:           24.0.4API version:       1.43Go version:        go1.20.5Git commit:        3713ee1Built:             Fri Jul  7 14:54:21 2023OS/Arch:           linux/amd64Context:           default
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?[root@docker-01 ~]# systemctl start docker
[root@docker-01 ~]# systemctl enable docker[root@docker-01 ~]# tar -zcvf docker-ce.tar.gz docker-ce/
[root@docker-01 ~]# scp -rp docker-ce.tar.gz root@10.0.0.52:/root
The authenticity of host '10.0.0.52 (10.0.0.52)' can't be established.
ECDSA key fingerprint is 91:14:1f:5c:f9:69:6e:12:5f:fa:dd:61:bc:ef:3e:68.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.52' (ECDSA) to the list of known hosts.
root@10.0.0.52's password: 
docker-ce.tar.gz                                                 100%  116MB 116.5MB/s   00:01   

 docker-02

[root@docker-02 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0   6100      0 --:--:-- --:--:-- --:--:--  6108[root@docker-02 ~]# tar xf docker-ce.tar.gz 
[root@docker-02 ~]# cd docker-ce/
[root@docker-02 docker-ce]# yum localinstall -y *.rpm[root@docker-02 docker-ce]# systemctl start docker
[root@docker-02 docker-ce]# systemctl enable docker[root@docker-02 docker-ce]# docker version 
Client: Docker Engine - CommunityVersion:           24.0.4API version:       1.43Go version:        go1.20.5Git commit:        3713ee1Built:             Fri Jul  7 14:54:21 2023OS/Arch:           linux/amd64Context:           default

【2】docker常用命令 

搜索镜像 - search

[root@docker-01 ~]# docker search nginx
NAME                                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                                             Official build of Nginx.                        18762     [OK]       
unit                                              Official build of NGINX Unit: Universal Web …   6         [OK]       

下载镜像 - pull

[root@docker-01 ~]# docker pull nginx:latest
latest: Pulling from library/nginx
faef57eae888: Pull complete 
76579e9ed380: Pull complete 
cf707e233955: Pull complete 
91bb7937700d: Pull complete 
4b962717ba55: Pull complete 
f46d7b05649a: Pull complete 
103501419a0a: Pull complete 
Digest: sha256:08bc36ad52474e528cc1ea3426b5e3f4bad8a130318e3140d6cfe29c8892c7ef
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest

 查看存在的镜像 - image ls

[root@docker-01 ~]# docker image ls
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    021283c8eb95   12 days ago   187MB## 或使用 images
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    021283c8eb95   12 days ago   187MB

 删除镜像 - image rm

[root@docker-01 ~]# docker image rm nginx:latest 
Untagged: nginx:latest
Untagged: nginx@sha256:08bc36ad52474e528cc1ea3426b5e3f4bad8a130318e3140d6cfe29c8892c7ef
Deleted: sha256:021283c8eb95be02b23db0de7f609d603553c6714785e7a673c6594a624ffbda
Deleted: sha256:a9de33035096cdf7bbaf7f3e1291701c0620d2a0e66152228abef35a79002876
Deleted: sha256:d66c35807d98c6f37bd2a14c6506a42d27a40fbdb564e233f7a78aafdc636c59
Deleted: sha256:a4c423818ed6dc12a545c349d0dc36a5695446448e07229e96c7235a126c2520
Deleted: sha256:c04094edc9df98c870e281f3b947a7782ca6d542d8715814ac06786466af3659
Deleted: sha256:c9c467815e8fe87d99f0f500495cf7f4f9096cf6c116ef2782e84bb17a4a5e06
Deleted: sha256:4645f26713fbea51190f5de52b88fbe27b42efd61c0dba87c81fa16df9a8f649
Deleted: sha256:24839d45ca455f36659219281e0f2304520b92347eb536ad5cc7b4dbb8163588[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE## 或使用 rmi
[root@docker-01 ~]# docker pull nginx:latest
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    021283c8eb95   12 days ago   187MB
[root@docker-01 ~]# docker rmi nginx:latest 
Untagged: nginx:latest
Untagged: nginx@sha256:08bc36ad52474e528cc1ea3426b5e3f4bad8a130318e3140d6cfe29c8892c7ef
Deleted: sha256:021283c8eb95be02b23db0de7f609d603553c6714785e7a673c6594a624ffbda
Deleted: sha256:a9de33035096cdf7bbaf7f3e1291701c0620d2a0e66152228abef35a79002876
Deleted: sha256:d66c35807d98c6f37bd2a14c6506a42d27a40fbdb564e233f7a78aafdc636c59
Deleted: sha256:a4c423818ed6dc12a545c349d0dc36a5695446448e07229e96c7235a126c2520
Deleted: sha256:c04094edc9df98c870e281f3b947a7782ca6d542d8715814ac06786466af3659
Deleted: sha256:c9c467815e8fe87d99f0f500495cf7f4f9096cf6c116ef2782e84bb17a4a5e06
Deleted: sha256:4645f26713fbea51190f5de52b88fbe27b42efd61c0dba87c81fa16df9a8f649
Deleted: sha256:24839d45ca455f36659219281e0f2304520b92347eb536ad5cc7b4dbb8163588
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

 导出镜像 - save

[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    021283c8eb95   12 days ago   187MB
alpine       latest    c1aabb73d233   4 weeks ago   7.33MB
[root@docker-01 ~]# docker save nginx:latest -o docker_nginx_latest.tar.gz
[root@docker-01 ~]# ls
anaconda-ks.cfg  docker_nginx_latest.tar.gz

 将多个镜像导出到同一个tar包

[root@docker-01 ~]# docker save -o docker_nginx_latest_alpine_laster.tar.gz nginx:latest alpine:latest 
[root@docker-01 ~]# ls
anaconda-ks.cfg  docker_nginx_latest_alpine_laster.tar.gz

 导入镜像 - load

[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@docker-01 ~]# docker load -i docker_nginx_latest.tar.gz 
24839d45ca45: Loading layer [==================================================>]  77.81MB/77.81MB
b821d93f6666: Loading layer [==================================================>]  113.2MB/113.2MB
1998c5cd2230: Loading layer [==================================================>]  3.584kB/3.584kB
f36897eea34d: Loading layer [==================================================>]  4.608kB/4.608kB
9fdfd12bc85b: Loading layer [==================================================>]   2.56kB/2.56kB
434c6a715c30: Loading layer [==================================================>]   5.12kB/5.12kB
3c9d04c9ebd5: Loading layer [==================================================>]  7.168kB/7.168kB
Loaded image: nginx:latest
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    021283c8eb95   12 days ago   187MB[root@docker-01 ~]# docker load -i docker_nginx_latest_alpine_laster.tar.gz 
Loaded image: nginx:latest
78a822fe2a2d: Loading layer [==================================================>]  7.622MB/7.622MB
Loaded image: alpine:latest
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    021283c8eb95   12 days ago   187MB
alpine       latest    c1aabb73d233   4 weeks ago   7.33MB

导入镜像 - import (使用import导入的镜像,没有名称和tag)

[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@docker-01 ~]# docker import docker_nginx_latest.tar.gz 
sha256:3a1b69daa7117d4087d303a9b9f8264bd6ddd89fc0aa98de15279bc54fd6417f
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
<none>       <none>    3a1b69daa711   8 seconds ago   191MB

 镜像打标签tag - tag

[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
<none>       <none>    50e01e030252   7 seconds ago   191MB
[root@docker-01 ~]# docker tag 50e01e030252 nignx:latest
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
nignx        latest    50e01e030252   36 seconds ago   191MB

 批量导入镜像

[root@docker-01 ~]# ls 
anaconda-ks.cfg  docker_alpine_latest.tar.gz  docker_nginx_latest.tar.gz
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@docker-01 ~]# for i in `ls *.tar.gz` ; do docker load -i ${i} ; done
78a822fe2a2d: Loading layer [==================================================>]  7.622MB/7.622MB
Loaded image: alpine:latest
24839d45ca45: Loading layer [==================================================>]  77.81MB/77.81MB
b821d93f6666: Loading layer [==================================================>]  113.2MB/113.2MB
1998c5cd2230: Loading layer [==================================================>]  3.584kB/3.584kB
f36897eea34d: Loading layer [==================================================>]  4.608kB/4.608kB
9fdfd12bc85b: Loading layer [==================================================>]   2.56kB/2.56kB
434c6a715c30: Loading layer [==================================================>]   5.12kB/5.12kB
3c9d04c9ebd5: Loading layer [==================================================>]  7.168kB/7.168kB
Loaded image: nginx:latest
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    021283c8eb95   12 days ago   187MB
alpine       latest    c1aabb73d233   4 weeks ago   7.33MB

查看镜像属性信息 - inspect

[root@docker-01 ~]# docker image inspect nignx:latest 
[{"Id": "sha256:50e01e0302529b75135cdb604390e902edf0d2d33b15a4aad38549364d8a783d","RepoTags": ["nignx:latest"],"RepoDigests": [],"Parent": "","Comment": "Imported from -","Created": "2023-07-17T14:00:39.736859118Z","Container": "","ContainerConfig": {"Hostname": "","Domainname": "","User": "","AttachStdin": false,"AttachStdout": false,"AttachStderr": false,"Tty": false,"OpenStdin": false,"StdinOnce": false,"Env": null,"Cmd": null,"Image": "","Volumes": null,"WorkingDir": "","Entrypoint": null,"OnBuild": null,"Labels": null},"DockerVersion": "24.0.4","Author": "","Config": {"Hostname": "","Domainname": "","User": "","AttachStdin": false,"AttachStdout": false,"AttachStderr": false,"Tty": false,"OpenStdin": false,"StdinOnce": false,"Env": null,"Cmd": null,"Image": "","Volumes": null,"WorkingDir": "","Entrypoint": null,"OnBuild": null,"Labels": null},"Architecture": "amd64","Os": "linux","Size": 191044723,"VirtualSize": 191044723,"GraphDriver": {"Data": {"MergedDir": "/var/lib/docker/overlay2/26712e0da7400f397726cf91ce493a57ddba45fd2888eef4c47a02cb09b3c611/merged","UpperDir": "/var/lib/docker/overlay2/26712e0da7400f397726cf91ce493a57ddba45fd2888eef4c47a02cb09b3c611/diff","WorkDir": "/var/lib/docker/overlay2/26712e0da7400f397726cf91ce493a57ddba45fd2888eef4c47a02cb09b3c611/work"},"Name": "overlay2"},"RootFS": {"Type": "layers","Layers": ["sha256:3535316b441652de429ba1b43116475d9096fe29db21febf279c6d34edf7a8f0"]},"Metadata": {"LastTagTime": "2023-07-17T22:01:13.237222336+08:00"}}
]

 清理无名、无效的镜像 - prune

[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
<none>       <none>    7a3926d49b5c   3 seconds ago   7.62MB
nignx        latest    50e01e030252   2 minutes ago   191MB
[root@docker-01 ~]# docker image prune 
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:7a3926d49b5c85905e58e97413bb3867e8b4584b4d88a22392ae8d70de6ebd0a
deleted: sha256:827bcdd7ee4f04b14a30f473be61643971d64a7bacb639c1ad1f99d133598987Total reclaimed space: 7.625MB
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
nignx        latest    50e01e030252   2 minutes ago   191MB

 批量删除镜像、删除没有容器使用的镜像 - system prune

[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
nignx        latest    50e01e030252   3 minutes ago   191MB
alpine       latest    c1aabb73d233   4 weeks ago     7.33MB
[root@docker-01 ~]# docker system prune -a
WARNING! This will remove:- all stopped containers- all networks not used by at least one container- all images without at least one container associated to them- all build cacheAre you sure you want to continue? [y/N] y
Deleted Images:
untagged: nignx:latest
deleted: sha256:50e01e0302529b75135cdb604390e902edf0d2d33b15a4aad38549364d8a783d
deleted: sha256:3535316b441652de429ba1b43116475d9096fe29db21febf279c6d34edf7a8f0
untagged: alpine:latest
deleted: sha256:c1aabb73d2339c5ebaa3681de2e9d9c18d57485045a4e311d9f8004bec208d67
deleted: sha256:78a822fe2a2d2c84f3de4a403188c45f623017d6a4521d23047c9fbb0801794cTotal reclaimed space: 198.4MB
[root@docker-01 ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@docker-01 ~]# 

创建、启动容器 - run -dit

[root@docker-01 ~]# docker run -dit nginx:latest 
a5ff63d7068da615129595535c0be909ee2055feb836e0584370e19a0fb7181d
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS     NAMES
a5ff63d7068d   nginx:latest   "/docker-entrypoint.…"   10 seconds ago   Up 10 seconds   80/tcp    romantic_shtern
[root@docker-01 ~]# 

创建、启动并直接进入容器 - run -it (但是退出后,容器会死掉)

[root@docker-01 ~]# docker run -it alpine:latest 
/ # ls
bin    dev    etc    home   lib    media  mnt    opt    proc   root   run    sbin   srv    sys    tmp    usr    var
/ # exit
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED          STATUS                     PORTS     NAMES
c6e57a2ae517   alpine:latest   "/bin/sh"                15 seconds ago   Exited (0) 2 seconds ago             suspicious_ishizaka

 创建、启动容器让容器一直处于运行状态

[root@docker-01 ~]# docker run -dit alpine:latest 
1f602a2a733ef393edfb32e4958d5169dd40e6f8000e746e96c0743934a2b8e3
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED              STATUS                          PORTS     NAMES
1f602a2a733e   alpine:latest   "/bin/sh"                6 seconds ago        Up 5 seconds                              hungry_chatelet[root@docker-01 ~]# docker exec -it 1f602a2a733e /bin/ash
/ # exit
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED          STATUS                          PORTS     NAMES
1f602a2a733e   alpine:latest   "/bin/sh"                34 seconds ago   Up 34 seconds                             hungry_chatelet

创建容器,但是不启动 - create 

[root@docker-01 ~]# docker create alpine:latest 
dff9b9819f1ea4d9a472552c5cccf950e8900e08925388f22b304cc0a4881844
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED              STATUS                     PORTS     NAMES
dff9b9819f1e   alpine:latest   "/bin/sh"                3 seconds ago        Created                              trusting_liskov

 创建容器,并指定容器名称 - name

[root@docker-01 ~]# docker run -dit --name test centos:latest
f2e7ddb5c9a3518d6145cd40c4f05813ee788ca33d36cdc2a155896e97d8f08c
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE            COMMAND       CREATED          STATUS          PORTS                               NAMES
f2e7ddb5c9a3   centos:latest    "/bin/bash"   8 seconds ago    Up 7 seconds                                        test

docker服务重启后,自动拉起容器运行

[root@docker-01 ~]# docker run -dit --name test-01 --restart=unless-stopped nginx:latest 
96ce404fc5aab56a290d0da1146b1c5222951d4c02e84e7ac97017527347f8c2
[root@docker-01 ~]# ----restart=unless-stopped :docker重启后,自动拉起(但是不包含在守护进程重启之前就停止的容器)
----restart=no             : docker重启后, 不自动拉起容器
--restart=always           :docker重启后, 总是拉起容器
--restart=on-failure:3     :docker服务不正常退出并重启后,自动拉起服务,若超过指定3次未拉起容器则放弃

  创建容器,并指定容器最大使用内存 - memory

[root@docker-01 ~]# docker run -dit --name test-mem --memory 256m centos:latest 
927a4400a7570dc04768219aac08188aca5412cd15b6eba91eb42a63c28f9e3b
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE            COMMAND       CREATED          STATUS          PORTS                               NAMES
927a4400a757   centos:latest    "/bin/bash"   5 seconds ago    Up 5 seconds                                        test-mem[root@docker-01 ~]# docker stats --no-stream 
CONTAINER ID   NAME                CPU %     MEM USAGE / LIMIT     MEM %     NET I/O          BLOCK I/O         PIDS
927a4400a757   test-mem            0.00%     536KiB / 256MiB       0.20%     648B / 0B        0B / 0B           1[root@docker-01 ~]# docker inspect test-mem | grep -i mem"Name": "/test-mem","Memory": 268435456,"CpusetMems": "","MemoryReservation": 0,"MemorySwap": 536870912,"MemorySwappiness": null,

 容器配置swap - memory-swap

[root@docker-01 ~]# docker run -dit --name test --memory 300m --memory-swap 300m nginx:latest 
f86590ceb190c3f4768841e00daa3498e8a52d03ba37acc2c5321f1c7a655ff4[root@docker-01 ~]# docker run -dit --name test-01 --memory 300m --memory-swap 300m centos:latest 
ad33ab277600a5ecb0c6074d37a0cd9510113827e73bea8d032f2a09245a5cb1[root@docker-01 ~]# docker stats --no-stream 
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O     BLOCK I/O     PIDS
ad33ab277600   test-01   0.00%     540KiB / 300MiB     0.18%     648B / 0B   0B / 0B       1
f86590ceb190   test      0.00%     6.344MiB / 300MiB   2.11%     648B / 0B   26.4MB / 0B   2[root@docker-01 ~]# docker inspect test | grep  -i mem"Memory": 314572800,"CpusetMems": "","MemoryReservation": 0,"MemorySwap": 314572800,"MemorySwappiness": null,[root@docker-01 ~]# docker inspect test-01 | grep  -i mem"Memory": 314572800,"CpusetMems": "","MemoryReservation": 0,"MemorySwap": 314572800,"MemorySwappiness": null,

 设置容器不被kill

  • 容器在运行中,如果内存使用超出最大限制后,docker会将容器杀死,但是容器中有些服务会很重要,不能被杀死
[root@docker-01 ~]# docker run -dit --name test --memory 256m --memory-swap 256m --no-healthcheck=false nginx:latest 
0ea31b515ca8dbb3fcf4976647ec9761198d4f432be98f5ef4ce8bb417c4c4ac[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
0ea31b515ca8   nginx:latest   "/docker-entrypoint.…"   7 seconds ago   Up 6 seconds   80/tcp    test[root@docker-01 ~]# docker stats --no-stream 
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O     BLOCK I/O   PIDS
0ea31b515ca8   test      0.00%     1.797MiB / 256MiB   0.70%     648B / 0B   0B / 0B     2

容器内存扩容 

[root@docker-01 ~]# docker inspect test-01 | grep -i mem"Memory": 268435456,"CpusetMems": "","MemoryReservation": 0,"MemorySwap": 268435456,"MemorySwappiness": null,[root@docker-01 ~]# docker update --memory 512m --memory-swap 512m test-01 
test-01[root@docker-01 ~]# docker stats --no-stream 
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O     BLOCK I/O   PIDS
835765b53151   test-01   0.00%     1.801MiB / 512MiB   0.35%     648B / 0B   0B / 0B     2
[root@docker-01 ~]# docker inspect test-01 | grep -i mem"Memory": 536870912,"CpusetMems": "","MemoryReservation": 0,"MemorySwap": 536870912,"MemorySwappiness": null,

 容器只可以在cpu0上运行

[root@docker-01 ~]# docker run -dit --name test --memory 256m --memory-swap 256m --cpuset-cpus 0 nginx:latest 
5f4ea4c54fba032131d8df05d3f47d28d88054882ad174ab092166632d2467e2
[root@docker-01 ~]# docker stats --no-stream 
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O     BLOCK I/O   PIDS
5f4ea4c54fba   test      0.00%     1.801MiB / 256MiB   0.70%     648B / 0B   0B / 0B     2

 容器可以在cpu0-cpu1之间运行

[root@docker-01 ~]# docker run -dit --name test --memory 256m --memory-swap 256m --cpuset-cpus '0-1' nginx:latest

  容器只可以在cpu0、cpu1运行

[root@docker-01 ~]# docker run -dit --name test-02 --memory 256m --memory-swap 256m --cpuset-cpus '0,1' nginx:latest

 容器只能使用50%的CPU资源

[root@docker-01 ~]# docker run -dit --name test-01 --memory 256m --memory-swap 256m --cpuset-cpus 0 --cpu-shares 50 nginx:latest 
835765b53151d23cadc688aee2d69e373cf7ab4fe1931600b35e0e55b2cb9695[root@docker-01 ~]# docker inspect test-01 | grep -i cpu"CpuShares": 50,"NanoCpus": 0,"CpuPeriod": 0,"CpuQuota": 0,"CpuRealtimePeriod": 0,"CpuRealtimeRuntime": 0,"CpusetCpus": "0","CpusetMems": "","CpuCount": 0,"CpuPercent": 0,

 容器重命名 - rename

[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED              STATUS              PORTS     NAMES
a5ff63d7068d   nginx:latest   "/docker-entrypoint.…"   About a minute ago   Up About a minute   80/tcp    romantic_shtern
[root@docker-01 ~]# docker rename a5ff63d7068d nginx
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED              STATUS              PORTS     NAMES
a5ff63d7068d   nginx:latest   "/docker-entrypoint.…"   About a minute ago   Up About a minute   80/tcp    nginx
[root@docker-01 ~]# 

 进入容器、attach命令退出会容器停止 - attach

[root@docker-01 ~]# docker attach 4f2dd90101d7
/ # ls
bin    dev    etc    home   lib    media  mnt    opt    proc   root   run    sbin   srv    sys    tmp    usr    var
/ # exit
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED              STATUS                     PORTS     NAMES
4f2dd90101d7   alpine:latest   "/bin/sh"                31 seconds ago       Exited (0) 2 seconds ago             practical_poincare

 

  • 但是我们使用attach进入容器后,想退出但是不想容器死掉,使用 crtl + p + q,偷偷退出
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND     CREATED         STATUS         PORTS     NAMES
d6e4f2cdbdb7   alpine:latest   "/bin/sh"   8 seconds ago   Up 7 seconds             jovial_meninsky
[root@docker-01 ~]# docker attach d6e4f2cdbdb7
/ # ls
bin    dev    etc    home   lib    media  mnt    opt    proc   root   run    sbin   srv    sys    tmp    usr    var
/ # read escape sequence
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND     CREATED          STATUS          PORTS     NAMES
d6e4f2cdbdb7   alpine:latest   "/bin/sh"   27 seconds ago   Up 27 seconds             jovial_meninsky
[root@docker-01 ~]# 

 

  • 有意思的是:使用attach命令,不管是多少人进入这个容器,都是用的相同的终端下工作,所以说画面都是是同步的,执行的过程大家都能看到,当如果有人执行了exit,自己也会退出容器也会死掉

 进入容器exec,退出容器不会停止 - exec

[root@docker-01 ~]# docker exec -it jovial_meninsky /bin/sh
/ # ls
bin    dev    etc    home   lib    media  mnt    opt    proc   root   run    sbin   srv    sys    test   tmp    usr    var
/ # exit
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND     CREATED         STATUS          PORTS     NAMES
d6e4f2cdbdb7   alpine:latest   "/bin/sh"   6 minutes ago   Up 20 seconds             jovial_meninsky

 那么使用exec进入的容器为什么退出时容器不会死掉?他和attach有什么区别?

  • 1、exec 进入容器时需要指定方式/bin/sh,也就是说会在进入容器时生成新的终端并在此终端下作业,所以说不管多少人使用exec进入相同的容器,都不会是同一个终端,并不会影响其他人在容器中的作业

 查看启动、运行中的容器 - ps

[root@docker-01 ~]# docker ps
CONTAINER ID   IMAGE           COMMAND     CREATED          STATUS          PORTS     NAMES
d6e4f2cdbdb7   alpine:latest   "/bin/sh"   14 minutes ago   Up 22 seconds             jovial_meninsky# 或使用 container ls
[root@docker-01 ~]# docker container ls
CONTAINER ID   IMAGE           COMMAND     CREATED          STATUS          PORTS     NAMES
d6e4f2cdbdb7   alpine:latest   "/bin/sh"   14 minutes ago   Up 39 seconds             jovial_meninsky

 查看所有容器 - ps -a

[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED          STATUS              PORTS     NAMES
4cc6e2bd2878   nginx:latest    "/docker-entrypoint.…"   30 seconds ago   Created                       boring_hoover
d6e4f2cdbdb7   alpine:latest   "/bin/sh"                16 minutes ago   Up About a minute             jovial_meninsky
[root@docker-01 ~]#

 查看最新创建的容器

[root@docker-01 ~]# docker ps -a -l
CONTAINER ID   IMAGE          COMMAND                  CREATED              STATUS    PORTS     NAMES
4cc6e2bd2878   nginx:latest   "/docker-entrypoint.…"   About a minute ago   Created             boring_hoover

 删除容器 - rm(只能删除停止的容器)

[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS         PORTS     NAMES
546bc01de58e   alpine:latest   "/bin/sh"                2 minutes ago   Up 6 seconds             pedantic_morse
4ff3ae3ab2b7   nginx:latest    "/docker-entrypoint.…"   3 minutes ago   Up 6 seconds   80/tcp    musing_jackson
[root@docker-01 ~]# docker stop 546bc01de58e
546bc01de58e[root@docker-01 ~]# docker rm pedantic_morse 
pedantic_morse
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS          PORTS     NAMES
4ff3ae3ab2b7   nginx:latest   "/docker-entrypoint.…"   3 minutes ago   Up 36 seconds   80/tcp    musing_jackson
[root@docker-01 ~]# 

 强制删除正在运行中的容器 - f

[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS          PORTS     NAMES
4ff3ae3ab2b7   nginx:latest   "/docker-entrypoint.…"   6 minutes ago   Up 46 seconds   80/tcp    musing_jackson
[root@docker-01 ~]# docker rm -f musing_jackson 
musing_jackson
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@docker-01 ~]#

 批量删除容器 - rm(rm:只能删除停止的容器 ,-f :删除所有,包含运行中的容器)

[root@docker-01 ~]# docker rm -f $(docker ps -aq)
4cc6e2bd2878
d6e4f2cdbdb7[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

 删除已经停止的容器

[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS                     PORTS     NAMES
796a3ad06ca9   nginx:latest   "/docker-entrypoint.…"   22 seconds ago   Exited (0) 9 seconds ago             test-01
cccbebdc927e   nginx:latest   "/docker-entrypoint.…"   27 seconds ago   Up 26 seconds              80/tcp    test-02
61b7b8736291   nginx:latest   "/docker-entrypoint.…"   33 seconds ago   Exited (0) 2 seconds ago             test-04
d4ef395e0e5e   nginx:latest   "/docker-entrypoint.…"   36 seconds ago   Up 36 seconds              80/tcp    test-03[root@docker-01 ~]# docker ps -a | grep Exit | awk '{print $NF}' | xargs docker rm
test-01
test-04
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
cccbebdc927e   nginx:latest   "/docker-entrypoint.…"   2 minutes ago   Up 2 minutes   80/tcp    test-02
d4ef395e0e5e   nginx:latest   "/docker-entrypoint.…"   2 minutes ago   Up 2 minutes   80/tcp    test-03

停止容器 - stop

[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS              PORTS     NAMES
4ff3ae3ab2b7   nginx:latest   "/docker-entrypoint.…"   4 minutes ago   Up About a minute   80/tcp    musing_jackson
[root@docker-01 ~]# docker stop 4ff3ae3ab2b7
4ff3ae3ab2b7
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS                     PORTS     NAMES
4ff3ae3ab2b7   nginx:latest   "/docker-entrypoint.…"   5 minutes ago   Exited (0) 4 seconds ago             musing_jackson
[root@docker-01 ~]# 

 批量停止容器

[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS         PORTS     NAMES
546bc01de58e   alpine:latest   "/bin/sh"                3 seconds ago   Up 3 seconds             pedantic_morse
4ff3ae3ab2b7   nginx:latest    "/docker-entrypoint.…"   8 seconds ago   Up 7 seconds   80/tcp    musing_jackson
[root@docker-01 ~]# docker stop $(docker ps -aq)
546bc01de58e
4ff3ae3ab2b7
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED          STATUS                       PORTS     NAMES
546bc01de58e   alpine:latest   "/bin/sh"                29 seconds ago   Exited (137) 4 seconds ago             pedantic_morse
4ff3ae3ab2b7   nginx:latest    "/docker-entrypoint.…"   34 seconds ago   Exited (0) 14 seconds ago              musing_jackson
[root@docker-01 ~]# 

 我们发现使用stop停止容器,过程会很慢,可以使用kill强制停止

[root@docker-01 ~]# docker kill $(docker ps -aq)
546bc01de58e
4ff3ae3ab2b7
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED              STATUS                       PORTS     NAMES
546bc01de58e   alpine:latest   "/bin/sh"                About a minute ago   Exited (137) 3 seconds ago             pedantic_morse
4ff3ae3ab2b7   nginx:latest    "/docker-entrypoint.…"   2 minutes ago        Exited (137) 3 seconds ago             musing_jackson
[root@docker-01 ~]# 

 重启容器 - restart

[root@docker-01 ~]# docker restart musing_jackson 
musing_jackson
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
4ff3ae3ab2b7   nginx:latest   "/docker-entrypoint.…"   5 minutes ago   Up 2 seconds   80/tcp    musing_jackson
[root@docker-01 ~]# 

 查看容器中使用的系统

[root@docker-01 ~]# docker run -dit alpine:latest 
6f422cf9500c53f10f12119a2706b8faf33303947ec9aea8dbf6428c81e8c77d
[root@docker-01 ~]# docker exec trusting_engelbart cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.18.2
PRETTY_NAME="Alpine Linux v3.18"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
[root@docker-01 ~]# 

将更改过的容器提交为一个新的镜像 - commit

[root@docker-01 ~]# docker exec -it cool_mendeleev /bin/bash
[root@cd3eb28ffbd0 /]# cat > /etc/yum.repos.d/nginx.repo << OK
> [nginx-stable]
> name=nginx stable repo
> baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/
> gpgcheck=0
> enabled=1
> gpgkey=https://nginx.org/keys/nginx_signing.key
> module_hotfixes=true
> OK
[root@cd3eb28ffbd0 /]# yum -y install nginx
[root@a121db69daff /]# nginx
[root@cd3eb28ffbd0 /]# exit
exit[root@docker-01 ~]# docker commit cool_mendeleev nginx/centos:7
sha256:daa47d59f276ad84e8a0e09547f2958f62e7bf15431850f64d5e7d3bbdb6495d
[root@docker-01 ~]# docker images
REPOSITORY     TAG       IMAGE ID       CREATED         SIZE
nginx/centos   7         daa47d59f276   3 seconds ago   458MB
nginx          latest    021283c8eb95   12 days ago     187MB
alpine         latest    c1aabb73d233   4 weeks ago     7.33MB
centos         7         eeb6ee3f44bd   22 months ago   204MB
centos         latest    5d0da3dc9764   22 months ago   231MB[root@docker-01 ~]# docker run -dit -p 80:80 nginx/centos:7 
a121db69daff2260798d732c2ad37aa9c0cbb5a444e1c62d6aa03ec0950d3306
[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE            COMMAND       CREATED         STATUS         PORTS                               NAMES
a121db69daff   nginx/centos:7   "/bin/bash"   3 seconds ago   Up 2 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp   objective_ptolemy
cd3eb28ffbd0   centos:7         "/bin/bash"   3 minutes ago   Up 3 minutes  

在容器和宿主机中互相复制文件 - cp

[root@docker-01 ~]# touch test
[root@docker-01 ~]# mkdir dir[root@docker-01 ~]# docker cp test objective_ptolemy:/root
Successfully copied 1.54kB to objective_ptolemy:/root
[root@docker-01 ~]# docker cp dir objective_ptolemy:/root
Successfully copied 1.54kB to objective_ptolemy:/root[root@docker-01 ~]# docker exec -it a121db69daff /bin/bash
[root@a121db69daff /]# cd root/
[root@a121db69daff ~]# ls
anaconda-ks.cfg  dir  test

 查看容器和镜像是否进行改变 - diff

[root@docker-01 ~]# docker diff objective_ptolemy 
C /var
C /var/log
C /var/log/nginx
C /var/log/nginx/access.log
C /var/log/nginx/error.log
C /var/cache
C /var/cache/nginx
A /var/cache/nginx/client_temp
A /var/cache/nginx/fastcgi_temp
A /var/cache/nginx/proxy_temp
A /var/cache/nginx/scgi_temp
A /var/cache/nginx/uwsgi_temp
C /run
A /run/nginx.pid
C /root
A /root/test
A /root/dir
A /root/llll
C /root/.bash_history

 监控容器 - events

[root@docker-01 ~]# docker events
2023-07-17T23:24:20.956090809+08:00 container exec_die a121db69daff2260798d732c2ad37aa9c0cbb5a444e1c62d6aa03ec0950d3306 (execID=c83af3df8e9971ef24f8edc266a21096a4e5e6c6aabb65efae559e653bb48716, exitCode=0, image=nginx/centos:7, name=objective_ptolemy, org.label-schema.build-date=20201113, org.label-schema.license=GPLv2, org.label-schema.name=CentOS Base Image, org.label-schema.schema-version=1.0, org.label-schema.vendor=CentOS, org.opencontainers.image.created=2020-11-13 00:00:00+00:00, org.opencontainers.image.licenses=GPL-2.0-only, org.opencontainers.image.title=CentOS Base Image, org.opencontainers.image.vendor=CentOS)

将容器进程的文件导出到本地 - export

[root@docker-01 ~]# docker ps -a
CONTAINER ID   IMAGE            COMMAND       CREATED          STATUS          PORTS                               NAMES
a121db69daff   nginx/centos:7   "/bin/bash"   11 minutes ago   Up 11 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp   objective_ptolemy
cd3eb28ffbd0   centos:7         "/bin/bash"   15 minutes ago   Up 15 minutes                                       cool_mendeleev
[root@docker-01 ~]# docker export cd3eb28ffbd0 > test.tar
[root@docker-01 ~]# ls
anaconda-ks.cfg  test.tar

将export导出的文件,创建一个镜像 - import

[root@docker-01 ~]# docker import test.tar centos:7.1
sha256:783d6a9fa04516bb4cb1c781413c916f55781576e53f6ef83a8b365c94c8b4de
[root@docker-01 ~]# docker images
REPOSITORY     TAG       IMAGE ID       CREATED          SIZE
centos         7.1       783d6a9fa045   3 seconds ago    431MB

 查看容器的资源使用情况 - stats

[root@docker-01 ~]# docker stats a121db69daffCONTAINER ID   NAME                CPU %     MEM USAGE / LIMIT    MEM %     NET I/O           BLOCK I/O     PIDS
a121db69daff   objective_ptolemy   0.00%     2.93MiB / 1.781GiB   0.16%     2.71kB / 2.29kB   3.96MB / 0B   3[root@docker-01 ~]# docker stats --no-stream 
CONTAINER ID   NAME                CPU %     MEM USAGE / LIMIT     MEM %     NET I/O          BLOCK I/O         PIDS
a121db69daff   objective_ptolemy   0.00%     396KiB / 1GiB         0.04%     648B / 0B        0B / 0B           1
cd3eb28ffbd0   cool_mendeleev      0.00%     64.07MiB / 1.781GiB   3.51%     58.5MB / 233kB   16.3MB / 9.65MB   1

 查看容器日志 - logs

[root@docker-01 ~]# docker logs cool_mendeleev

  查看容器进程 - top

[root@docker-01 ~]# docker top objective_ptolemy 
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                21989               21968               0                   23:17               ?                   00:00:00            /bin/bash
root                22115               21968               0                   23:18               ?                   00:00:00            nginx: master process nginx
systemd+            22116               22115               0                   23:18               ?                   00:00:00            nginx: worker process

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/2186.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

H3C-Cloud Lab实验-OSPF配置实验

一、实验拓扑图 实验需求&#xff1a; 1、按照图示配置 IP 地址 2、按照图示分区域配置 OSPF &#xff0c;实现全网互通 3、为了路由结构稳定&#xff0c;要求路由器使用环回口作为 Router-id&#xff0c;ABR 的环回口宣告进骨干区域 4、掌握OSPF初始化流程、路由表学习的过…

el-progress组件使用,样式修改,自定义文字

正常的el-progress显示是这样的 修改后 自动计算percentage&#xff0c;format自定义显示文字 <template><div><div class"content-view"><div v-for"(item, index) in progressList" class"item-view"><el-prog…

解锁编程世界的魔法密码:探索算法的奥秘与应用

一个程序员一生中可能会邂逅各种各样的算法&#xff0c;但总有那么几种&#xff0c;是作为一个程序员一定会遇见且大概率需要掌握的算法。今天就来聊聊这些十分重要的“必抓&#xff01;”算法吧~* 一&#xff1a;引言 算法是解决问题和优化程序性能的核心&#xff0c;它是一…

你真的会用async和await么?

async函数搞懂 背景asyncawaitawait 知识点1await 知识点2await 知识点三await 知识点四await 知识点五 背景 背景就是遇到了一个比较烦人的模块&#xff0c;里面的涉及到了大量的async 和 awiat。发现大多人对这个语法糖一知半解&#xff0c;然后大量的滥用&#xff0c;整理一…

数据标注的类型有哪些?

构建像人类一样的AI或ML模型需要大量训练数据。要使模型做出决定并采取行动&#xff0c;就必须通过数据标注来训练模型&#xff0c;使其能够理解特定信息。 但是&#xff0c;什么是数据标注呢&#xff1f;数据标注是指对用于人工智能应用的数据进行分类和标注。我们必须针对特定…

Qt6 Qt Quick UI原型学习QML第二篇

Qt6 Qt Quick UI原型学习QML第二篇 界面效果QML语法语法讲解核心要素项目元素矩形元素文本元素图像元素MouseArea元素 界面效果 QML语法 import QtQuick 2.12 import QtQuick.Window 2.12Window {id: rootvisible: truewidth: 640height: 480title: qsTr("QML学习第二篇&…

用微服务架构推进企业数字化转型升级

随着数字化转型进入深水区&#xff0c;企业应用程序建设需求急剧增长且变化多端&#xff0c;软件架构经历了单体结构、垂直架构、SOA架构&#xff0c;发展到了现在的微服务架构。 单体架构目前应用较多&#xff0c;部署容易&#xff0c;但单体式应用内部包含了所有需要的服务&…

FPGA——点亮led灯

文章目录 一、实验环境二、实验任务三、实验过程3.1 编写verliog程序3.2 引脚配置 四、仿真4.1 仿真代码4.2仿真结果 五、实验结果六、总结 一、实验环境 quartus18.1 vscode Cyclone IV开发板 二、实验任务 每间隔1S实现led灯的亮灭&#xff0c;实现流水灯的效果。 三、实…

基于卡尔曼滤波进行四旋翼动力学建模(SimulinkMatlab)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

2.Docker镜像和容器操作

文章目录 Docker操作Docker镜像操作搜索镜像获取镜像镜像加速下载查看镜像详细信息为镜像添加标签删除镜像导出导入镜像上传镜像 Docker容器操作创建容器查看容器状态启动容器创建并启动容器进入容器停止容器删除容器复制容器文件到宿主机容器的导出导入 Docker操作 ###查看do…

vscode 端口转发实现端口映射,实现端口自由

用vscode连接server进行开发&#xff0c; 是非常方便的&#xff0c;但很多时候&#xff0c;server的端口开放的很有限&#xff0c;那么就可以利用vscode进行端口映射 举一个应用场景&#xff1a; 先通过A利用vscode 连接B&#xff0c;然后再vscode 的port窗口进行端口转发&…

SpringBoot中整合Sharding Sphere实现数据加解密/数据脱敏/数据库密文,查询明文

场景 为防止数据泄露&#xff0c;需要在插入等操作时将某表的字段在数据库中加密存储&#xff0c;在需要查询使用时明文显示。 Sharding Sphere ShardingSphere是一套开源的分布式数据库中间件解决方案组成的生态圈&#xff0c; 它由Sharding-JDBC、Sharding-Proxy和Shardi…

如何获取microstore商品详情接口php接口jason数据字段

随着科技的发展&#xff0c;API接口成为了各行业发展的最新趋势。在微店购物平台中&#xff0c;商品详情API接口的引入&#xff0c;为商家和消费者提供了更加便捷、高效的用户体验。本文将为大家详细介绍微店商品详情API接口的优势和使用方法 商品详情API接口的优势 1.提升用户…

【milvus】向量数据库,用来做以图搜图+人脸识别的特征向量

1. 安装milvus ref:https://milvus.io/docs 第一次装东西&#xff0c;要把遇到的问题和成功经验都记录下来。 1.Download the YAML file wget https://github.com/milvus-io/milvus/releases/download/v2.2.11/milvus-standalone-docker-compose.yml -O docker-compose.yml看…

JavaWeb项目【SpringBoot】——图书项目4.0【源码】:SpringBoot版本 springboot相关技术 项目应用

目录 项目简介思考 & 改进1.Jsp都是同步请求---->改成异步Ajax【完成】2.前端用Jsp技术落后----->用Vue框架【完成】3.架构问题&#xff1a;配置数据和Java代码耦合【完成】3.SQL语句和Java代码耦合【完成】4.架构问题&#xff1a;servlet只能处理一个请求5.响应方式…

Web前端工程师笔试题(合集)

Web前端开发工程师笔试题篇1 1. 在一个框架的属性面板中&#xff0c;不能设置下面哪一项。( C ) A.源文件 ; B.边框颜色 ; C.边框宽度 D.滚动条 2. CSS样式表根据所在网页的位置&#xff0c;可分为?(B ) A.行内样式表、内嵌样式表、混合样式表 B.行内样式表、内嵌样式表…

客户案例 | 数字化加速,金融企业实现3D打印式应用程序开发

关键发现&#xff1a; 客户痛点&#xff1a;传统开发周期长&#xff0c;流程复杂&#xff0c;难以满足杭银消金在企业快速发展过程中的应用开发需求&#xff1b;内部业务因为优先级不高&#xff0c;导致开发资源分配有限&#xff0c;更加迟滞了管理部门数字化转型的进度。 解决…

pytorch实现线性回归

转大佬笔记 代码&#xff1a; # -*- coding: utf-8 -*- # Time : 2023-07-14 14:57 # Author : yuer # FileName: exercise05.py # Software: PyCharm import matplotlib.pyplot as plt import torch# x,y是3行1列的矩阵&#xff0c;所以在[]中要分为3个[] x_data torch.…

03 QT对象树

Tips: QT通过对象树机制&#xff0c;能够自动、有效的组织和管理继承自QObject的Qt对象&#xff0c;不需要用户手动回收资源&#xff0c;系统自动调用析构函数。 验证对象树功能&#xff1a; 新建C文件 继承自QPushButton&#xff0c;但没有QPushButton&#xff0c;但有其父类…

谷歌Bard更新:支持中文提问和语音朗读

ChatGPT不断更新功能&#xff0c;从GPT-3到3.5&#xff0c;再到GPT-4&#xff0c;甚至最新的plus版已经支持图像处理和图表生成&#xff0c;而谷歌Bard却自从推出后就一直很安静&#xff0c;没有什么大动作。眼见被ChatGPT、Claude甚至是文心一言抢去了风头&#xff0c;自然心有…