连云港做网站哪家好,描述网站建设规范方法,企业网络营销策划方案范文,建站公司 网络服务Docker 笔记#xff08;二#xff09;–镜像
记录Docker 安装操作记录#xff0c;便于查询。
参考
链接: Docker 入门到实战教程(三)镜像和容器链接: docker中daemon.json各配置详解链接: docker容器/etc/docker/daemon.json配置文件详解链接: docker官方文档
环境
Cen…Docker 笔记二–镜像
记录Docker 安装操作记录便于查询。
参考
链接: Docker 入门到实战教程(三)镜像和容器链接: docker中daemon.json各配置详解链接: docker容器/etc/docker/daemon.json配置文件详解链接: docker官方文档
环境
Centos 7.9
操作
1.查看命令
// 查看全部命令
[rootcentos7-18 image]# docker command --help // 查看某一个命令例如查看run
[rootcentos7-18 image]# docker run --help 2.查询镜像
// 查询nginx命令
[rootcentos7-18 image]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 19234 [OK]
unit Official build of NGINX Unit: Universal Web … 17 [OK]
nginxinc/nginx-unprivileged Unprivileged NGINX Dockerfiles 133
nginx/nginx-ingress NGINX and NGINX Plus Ingress Controllers fo… 86
nginx/nginx-prometheus-exporter NGINX Prometheus Exporter for NGINX and NGIN… 33 Name源名称DESCRIPTION描述STARS星点赞数量OFFICIAL是否官方发布AUTOMATED是否自动构建
3.拉取镜像
// 默认拉取最新版
[rootcentos7-18 image]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a2abf6c4d29d: Pull complete
a9edb18cadd1: Pull complete
589b7251471a: Pull complete
186b1aaa4aa6: Pull complete
b4df32aa5a72: Pull complete
a0bcbecc962e: Pull complete
Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest 4.查看镜像
4.1. 查看所有镜像
[rootcentos7-18 image]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 22 months ago 141MB
redis latest 7614ae9453d1 23 months ago 113MB REPOSITORY表示镜像的仓库源TAG标签IMAGE IDIDCREATED创建时间SIZE大小 4.2. 查看镜像详细信息
[rootcentos7-18 image]# docker inspect nginx
[{Id: sha256:605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85,RepoTags: [nginx:latest],RepoDigests: [nginxsha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31],Parent: ,Comment: ,Created: 2021-12-29T19:28:29.892199479Z,Container: ca3e48389f7160bc9d9a892d316fcbba459344ee3679998739b1c3cd8e56f7da,ContainerConfig: {Hostname: ca3e48389f71,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_VERSION1.21.5,NJS_VERSION0.7.1,PKG_RELEASE1~bullseye],Cmd: [/bin/sh,-c,#(nop) ,CMD [\nginx\ \-g\ \daemon off;\]],Image: sha256:82941edee2f4d17c55563bb926387c3ae39fa1a99777f088bc9d3db885192209,Volumes: null,WorkingDir: ,Entrypoint: [/docker-entrypoint.sh],OnBuild: null,Labels: {maintainer: NGINX Docker Maintainers docker-maintnginx.com},StopSignal: SIGQUIT},DockerVersion: 20.10.7,Author: ,Config: {Hostname: ,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_VERSION1.21.5,NJS_VERSION0.7.1,PKG_RELEASE1~bullseye],Cmd: [nginx,-g,daemon off;],Image: sha256:82941edee2f4d17c55563bb926387c3ae39fa1a99777f088bc9d3db885192209,Volumes: null,WorkingDir: ,Entrypoint: [/docker-entrypoint.sh],OnBuild: null,Labels: {maintainer: NGINX Docker Maintainers docker-maintnginx.com},StopSignal: SIGQUIT},Architecture: amd64,Os: linux,Size: 141479488,VirtualSize: 141479488,GraphDriver: {Data: {LowerDir: /var/lib/docker/overlay2/8b0be5030647522bf7b1b39db844d8c650bd8133a00ac05b330879de438c0abb/diff:/var/lib/docker/overlay2/563d515cbd4227114e7adeb014737ce26c3238a9e54135141519c5870470a0e0/diff:/var/lib/docker/overlay2/690c4f6a17cb8cf1aabe042511f57c198281895336138ac474117c60a879cc30/diff:/var/lib/docker/overlay2/3de8af079b18dd20b726da9ce7a91836810e1effd694cc39cccfc63925626d2c/diff:/var/lib/docker/overlay2/b04d78c79c57a4b680bf3f66c56a33b683fd632182f630835ec67d3a400ff965/diff,MergedDir: /var/lib/docker/overlay2/fd8c77083cd9b2c0c9bd36ecf8ade515986d4d9cf536abea70ecb0440fed2907/merged,UpperDir: /var/lib/docker/overlay2/fd8c77083cd9b2c0c9bd36ecf8ade515986d4d9cf536abea70ecb0440fed2907/diff,WorkDir: /var/lib/docker/overlay2/fd8c77083cd9b2c0c9bd36ecf8ade515986d4d9cf536abea70ecb0440fed2907/work},Name: overlay2},RootFS: {Type: layers,Layers: [sha256:2edcec3590a4ec7f40cf0743c15d78fb39d8326bc029073b41ef9727da6c851f,sha256:e379e8aedd4d72bb4c529a4ca07a4e4d230b5a1d3f7a61bc80179e8f02421ad8,sha256:b8d6e692a25e11b0d32c5c3dd544b71b1085ddc1fddad08e68cbd7fda7f70221,sha256:f1db227348d0a5e0b99b15a096d930d1a69db7474a1847acbc31f05e4ef8df8c,sha256:32ce5f6a5106cc637d09a98289782edf47c32cb082dc475dd47cbf19a4f866da,sha256:d874fd2bc83bb3322b566df739681fbd2248c58d3369cb25908d68e7ed6040a6]},Metadata: {LastTagTime: 0001-01-01T00:00:00Z}}
] 4.3. 查看镜像中间层
[rootcentos7-18 image]# docker images -a 如果不同镜像之间有复用的中间层这里就会看见一些没有镜像名和标签的镜像很多镜像依赖这些中间层所以中间层镜像是不能随意删除的。 4.4. 查看镜像中间层
[rootcentos7-18 image]# docker images -a 5.删除镜像
5.1. 删除镜像
// 删除镜像
[rootcentos7-18 image]# docker rmi hello-world
// 强制删除镜像
[rootcentos7-18 image]# docker rmi -f hello-world 5.2. 删除虚悬镜像
[rootcentos7-18 image]# docker image prune docker images (不加-a)显示的没有名称和标签的镜像叫虚悬镜像没有实际用途可以清除。
6.导出镜像
[rootcentos7-18 ~]# docker save -o hello-word.tar hello-world
[rootcentos7-18 ~]# ls
anaconda-ks.cfg hello-word.tar-o 参数后面接着输出文件名。hello-world是需要导出的镜像名。
7.导入镜像
[rootcentos7-18 ~]# docker load -i hello-word.tar
e07ee1baac5f: Loading layer [] 14.85kB/14.85kB
Loaded image: hello-world:latest8.修改镜像名和TAG
[rootcentos7-18 ~]# docker tag hello-world:latest hello-world:1.0
[rootcentos7-18 ~]# docker tag hello-world:latest hello-demo:1.0
[rootcentos7-18 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 22 months ago 141MB
redis latest 7614ae9453d1 23 months ago 113MB
hello-demo 1.0 feb5d9fea6a5 2 years ago 13.3kB
hello-world 1.0 feb5d9fea6a5 2 years ago 13.3kB
hello-world latest feb5d9fea6a5 2 years ago 13.3kB9.镜像存储位置
9.1. 存储位置
linux保存在“/var/lib/docker/”windows保存在“C:\ProgramData\DockerDesktop”Mac保存在“com.docker.docker/Data/vms/0/”
9.2. 修改位置 修改镜像存储与运行加载目录
[rootcentos7-18 ~]# vim /etc/docker/daemon.json{data-root: /data/var/lib/docker,
}[rootcentos7-18 docker]# systemctl daemon-reload
[rootcentos7-18 docker]# systemctl restart docker