Docker为什么会出现?
一款软件产品必须经过:开发 -> 上线
开发人员负责将应用程序开发制作出来。
运维人员负责上线,配置应用程序。
在这里存在一个问题:开发环境和上线环境不一致;可能会导致,开发人员在自己的电脑上可以正常运行代码,运维人员将服务程序上线到服务器后,由于环境不一致可能会导致运行失败,服务不可用。
如何解决上述问题?
- 对上线的服务器系统进行环境配置,但环境配置十分麻烦特别是集群部署时,集群中的每一台机器都需要部署环境。
- 将开发环境和程序代码一起打包到服务器中运行。
Docker就是将开发环境和程序代码一起打包到服务器中运行的技术。
java语言 --> apk程序 --> 发布到应用商店 --> 客户下载apk --> 安装使用(必须要有环境才能安装成功)
java语言 --> jar环境 --> 打包项目和环境(镜像) --> 上传到docker仓库(商店) --> 下载仓库中的镜像 --> 运行使用
Docker介绍
Docker是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的Linux或Windows机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。
Docker的核心思想就是来自集装箱;集装箱的概念是隔离货物,所以docker的核心就是隔离机制。同时docker使用可移植镜像所以部署以及运维极其方便快捷。
OCI&OCF
OCI
Open Container-initiative
- 由Linux基金会主导于2015年6月创立
- 旨在围绕容器格式和运行时制定一个开放的工业化标准
- contains two specifications
- the Runtime Specification(runtime-spec)
- the Image Specification(image-spec)
OCF
Open Container Format
runC是一个CLI工具,用于根据OCI规范生成和运行容器
- 容器作为runC的子进程启动,可以嵌入到各种其他系统中,而不需要运行守护进程
- runC是基于libcontainer构建的,同样的容器技术为数百万的Docker引擎安装提供了动力
docker提供了一个专门容纳容器镜像的站点:https://hub.docker.com
Docker发展史
2010年,几个热爱IT的年轻人,在美国成立了一家公司叫做dotCloud,主要做一些Paas的云计算服务和LXC有关的容器技术赚钱盈利,他们将自己的容器技术命名为Docker!
Docker刚刚诞生的时候,并没有引起行业的注意!这个时候 dotCloud公司难以在行业中存活,所以这几个年轻人选择开放Docker源代码来引起注意!
2013年,Docker开源!越来越多的人发现docker的优点,在这一段时间docker每个月都会更新一个版本。
2014年4月9日,Docker1.0发布!
容器和虚拟机的区别
虚拟机:通过虚拟化技术模拟真实的硬件从而创建出来的一台拥有完整功能的逻辑计算机。
Docker容器:docker容器也是一种虚拟化技术,和传统虚拟化不一样的是docker只模拟一个程序最核心的运行环境,所以十分小巧,启动更快。
Docker引擎架构
docker镜像与镜像仓库
为什么镜像仓库名字是Registry而不是repository?在docker中仓库的名字是以应用的名称取名的。
镜像是静态的,而容器是动态的,容器有其生命周期,镜像与容器的关系类似于程序与进程的关系。镜像类似于文件系统中的程序文件,而容器则类似于将一个程序运行起来的状态,也即进程。所以容器是可以删除的,容器被删除后其镜像是不会被删除的。
docker对象
当你使用docker时,你正在创建和使用图像、容器、网络、卷、插件和其他对象。
-
IMAGES
- 映像是一个只读模板,它带有创建docker容器的指令。
- 通常,一个映像基于另一个映像,并具有一些额外的自定义。
- 您可以创建自己的映像,也可以只使用其他人创建并在注册表中发布的映像。
-
CONTAINERS
- 容器是映像的可运行实例。
- 您可以通过docker API或CLI创建、运行、停止、移动或删除容器。
- 您可以将容器连接到一个或多个网络,将存储连接到它,甚至根据它的当前状态创建一个新映像。
Docker底层技术
- 名称空间:Docker通过名称空间机制为容器提供隔离的工作空间。
- 控制组:Linux可以通过控制组设置进程使用CPU、内存和I/O资源的限额。Docker引擎正是依赖这种底层技术来限制容器使用的资源。
- 联合文件系统:可以将其他文件系统合并到一个联合挂载点。联合文件系统是实现Docker镜像的技术基础。Docker镜像可以通过分层来实现继承。
- 容器格式:Docker引擎将名称空间、控制组和联合文件系统打包到一起所使用的就是容器格式。默认的容器格式是Libcontainer。
Docker优势和用例
Docker优势:
应用程序快速、一致地交付
- 开发人员在本地编写应用程序代码,通过Docker与同事进行共享。
- 通过Docker将应用程序推送到测试环境中,执行自动测试和手动测试。
- 开发人员发现程序错误时,可以在开发环境中进行修复,然后重新部署到测试环境来进行测试和验证。
- 完成应用程序测试之后,向客户提供补丁程序非常简单,只需将更新后的镜像推送到生产环境中。
响应式部署和伸缩应用程序
更简单的系统运维
更高效的计算资源利用
Docker用例:
现代应用程序
微服务
持续集成和持续部署
大数据应用
边缘计算
云迁移
数字化转型
传统Windows服务器应用程序的现代化
Docker名词解释
镜像(image):docker镜像就好比是一个模板,可以通过这个模板来创建容器服务;一个镜像可以创建多个容器(应用运行在容器中)。
容器(container):docker容器可以独立运行一个或者一组应用程序;容器是由镜像创建出来的。
仓库(repository):docker仓库是存放镜像的地方;docker仓库分为公有仓库和私有仓库。docker默认仓库是Docker Hub。
Docker环境部署
//首先配置yum仓库,此处省略yum仓库配置
//卸载系统自带的podman容器
yum -y remove podman-manpages
//部署安装docker所需要的环境
yum install -y yum-utils device-mapper-persistent-data lvm2
//配置docker的yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
//安装docker-ce以及docker组件
yum install -y docker-ce docker-ce-cli containerd.io
//启动docker服务并设置开机自启
systemctl start docker.service
systemctl enable docker.service
//设置docker hub阿里云镜像加速
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://1aq1u7oh.mirror.aliyuncs.com"]
}
EOF
//后面的地址应该放自己阿里云的镜像加速地址
systemctl daemon-reload
systemctl restart docker
docker常用操作
docker search:在Docker Hub中搜索图像
[root@localhost ~]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 15899 [OK]
jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 2098 [OK]
richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 819 [OK]
jc21/nginx-proxy-manager Docker container for managing Nginx proxy ho… 285
linuxserver/nginx An Nginx container, brought to you by LinuxS… 160
tiangolo/nginx-rtmp Docker image with Nginx using the nginx-rtmp… 146 [OK]
jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager 144 [OK]
alfg/nginx-rtmp NGINX, nginx-rtmp-module and FFmpeg from sou… 110 [OK]
nginxdemos/hello NGINX webserver that serves a simple page co… 79 [OK]
privatebin/nginx-fpm-alpine PrivateBin running on an Nginx, php-fpm & Al… 60 [OK]
nginx/nginx-ingress NGINX and NGINX Plus Ingress Controllers fo… 57
nginxinc/nginx-unprivileged Unprivileged NGINX Dockerfiles 54
nginxproxy/nginx-proxy Automated Nginx reverse proxy for docker con… 28
staticfloat/nginx-certbot Opinionated setup for automatic TLS certs lo… 25 [OK]
nginx/nginx-prometheus-exporter NGINX Prometheus Exporter for NGINX and NGIN… 22
schmunk42/nginx-redirect A very simple container to redirect HTTP tra… 19 [OK]
centos/nginx-112-centos7 Platform for running nginx 1.12 or building … 16
centos/nginx-18-centos7 Platform for running nginx 1.8 or building n… 13
flashspys/nginx-static Super Lightweight Nginx Image 11 [OK]
mailu/nginx Mailu nginx frontend 9 [OK]
sophos/nginx-vts-exporter Simple server that scrapes Nginx vts stats a… 7 [OK]
ansibleplaybookbundle/nginx-apb An APB to deploy NGINX 3 [OK]
wodby/nginx Generic nginx 1 [OK]
arnau/nginx-gate Docker image with Nginx with Lua enabled on … 1 [OK]
centos/nginx-110-centos7 Platform for running nginx 1.10 or building … 0
docker pull:从注册表中拉出映像或存储库
//不指定版本
[root@localhost ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
eff15d958d66: Pull complete
1e5351450a59: Pull complete
2df63e6ce2be: Pull complete
9171c7ae368c: Pull complete
020f975acd28: Pull complete
266f639b35ad: Pull complete
Digest: sha256:097c3a0913d7e3a5b01b6c685a60c03632fc7a2b50bc8e35bcaa3691d788226e
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
//指定版本
[root@localhost ~]# docker pull httpd:2.4.51
2.4.51: Pulling from library/httpd
eff15d958d66: Already exists
ba1caf8ba86c: Pull complete
ab86dc02235d: Pull complete
0d58b11d2867: Pull complete
e88da7cb925c: Pull complete
Digest: sha256:1d71eef54c08435c0be99877c408637f03112dc9f929fba3cccdd15896099b02
Status: Downloaded newer image for httpd:2.4.51
docker.io/library/httpd:2.4.51
docker images:图片列表
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd 2.4.51 ad17c88403e2 12 days ago 143MB
nginx latest ea335eea17ab 2 weeks ago 141MB
docker create:创建一个新的容器
//不指定版本
[root@localhost ~]# docker create nginx
c41436dfd54e71059b29147afa2bec6064f11e0635b7297ac45e32e95b4dc4b5
//指定版本
[root@localhost ~]# docker create httpd:2.4.51
80bd81dd51bc79382d96d911b35adceaaa15cec0ff9e73b4579eb5b07799056b
docker start:启动一个或多个停止的容器
[root@localhost ~]# docker start c41436dfd54e
c41436dfd54e
docker run:在新容器中运行命令
[root@localhost ~]# docker run -it httpd /bin/bash
Unable to find image 'httpd:latest' locally
latest: Pulling from library/httpd
Digest: sha256:1d71eef54c08435c0be99877c408637f03112dc9f929fba3cccdd15896099b02
Status: Downloaded newer image for httpd:latest
root@30be4b91eb4e:/usr/local/apache2# dock ps
bash: dock: command not found
root@30be4b91eb4e:/usr/local/apache2#
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
30be4b91eb4e httpd "/bin/bash" 17 seconds ago Up 16 seconds 80/tcp naughty_kapitsa
docker attach:附加到一个运行的容器
[root@localhost ~]# docker attach naughty_kapitsa
root@30be4b91eb4e:/usr/local/apache2# exit
exit
docker ps:列表容器
//查看已启动容器
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c41436dfd54e nginx "/docker-entrypoint.…" 4 minutes ago Up 6 seconds 80/tcp friendly_hertz
//查看所有容器
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
80bd81dd51bc httpd:2.4.51 "httpd-foreground" 43 seconds ago Created zen_murdock
c41436dfd54e nginx "/docker-entrypoint.…" 2 minutes ago Created friendly_hertz
docker logs:获取容器的日志
[root@localhost ~]# docker logs 30be4b91eb4e
root@30be4b91eb4e:/usr/local/apache2# dock ps
bash: dock: command not found
root@30be4b91eb4e:/usr/local/apache2# exit
exit
docker restart:重启一个容器
[root@localhost ~]# docker restart c41436dfd54e
c41436dfd54e
docker stop:停止一个或多个运行中的容器
[root@localhost ~]# docker stop c41436dfd54e
c41436dfd54e
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
docker kill:杀死一个或多个运行中的容器
[root@localhost ~]# docker kill c41436dfd54e
c41436dfd54e
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3f4628124c7a nginx:latest "/docker-entrypoint.…" 2 minutes ago Exited (0) 57 seconds ago agitated_hertz
80bd81dd51bc httpd:2.4.51 "httpd-foreground" 9 minutes ago Created zen_murdock
c41436dfd54e nginx "/docker-entrypoint.…" 11 minutes ago Exited (137) 16 seconds ago friendly_hertz
docker rm:取出一个或多个容器
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
30be4b91eb4e httpd "/bin/bash" 2 minutes ago Up 43 seconds 80/tcp naughty_kapitsa
60589b2571d8 nginx "/docker-entrypoint.…" 5 minutes ago Exited (0) 3 minutes ago gallant_colden
80bd81dd51bc httpd:2.4.51 "httpd-foreground" 25 minutes ago Created zen_murdock
c41436dfd54e nginx "/docker-entrypoint.…" 27 minutes ago Exited (137) 16 minutes ago friendly_hertz
[root@localhost ~]# docker rm 60589b2571d8
60589b2571d8
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
30be4b91eb4e httpd "/bin/bash" 2 minutes ago Up 53 seconds 80/tcp naughty_kapitsa
80bd81dd51bc httpd:2.4.51 "httpd-foreground" 25 minutes ago Created zen_murdock
c41436dfd54e nginx "/docker-entrypoint.…" 27 minutes ago Exited (137) 16 minutes ago friendly_hertz
docker exec:在运行容器中运行命令
[root@localhost ~]# docker exec -it c41436dfd54e /bin/bash
root@c41436dfd54e:/#
docker info:显示整个系统的信息
[root@localhost ~]# docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.6.3-docker)
scan: Docker Scan (Docker Inc., v0.9.0)
Server:
Containers: 3
Running: 1
Paused: 0
Stopped: 2
Images: 2
Server Version: 20.10.11
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
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 logentries splunk syslog
Swarm: inactive
Runtimes: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
Default Runtime: runc
Init Binary: docker-init
containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc version: v1.0.2-0-g52b36a2
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 4.18.0-193.el8.x86_64
Operating System: Red Hat Enterprise Linux 8.2 (Ootpa)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.664GiB
Name: localhost.localdomain
ID: AXIA:7B3U:IXSS:JY43:QD4W:NYRC:YG6L:T6HI:IVK5:NXA3:OABF:N4JJ
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://1aq1u7oh.mirror.aliyuncs.com/
Live Restore Enabled: false
docker inspect:返回Docker对象的低级信息
[root@localhost ~]# docker inspect c41436dfd54e
[
{
"Id": "c41436dfd54e71059b29147afa2bec6064f11e0635b7297ac45e32e95b4dc4b5",
"Created": "2021-12-01T16:04:10.938145471Z",
"Path": "/docker-entrypoint.sh",
"Args": [
"nginx",
"-g",
"daemon off;"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 4394,
"ExitCode": 0,
"Error": "",
"StartedAt": "2021-12-01T16:32:37.572583103Z",
"FinishedAt": "2021-12-01T16:15:03.903890067Z"
},
"Image": "sha256:ea335eea17ab984571cd4a3bcf90a0413773b559c75ef4cda07d0ce952b00291",
"ResolvConfPath": "/var/lib/docker/containers/c41436dfd54e71059b29147afa2bec6064f11e0635b7297ac45e32e95b4dc4b5/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/c41436dfd54e71059b29147afa2bec6064f11e0635b7297ac45e32e95b4dc4b5/hostname",
"HostsPath": "/var/lib/docker/containers/c41436dfd54e71059b29147afa2bec6064f11e0635b7297ac45e32e95b4dc4b5/hosts",
"LogPath": "/var/lib/docker/containers/c41436dfd54e71059b29147afa2bec6064f11e0635b7297ac45e32e95b4dc4b5/c41436dfd54e71059b29147afa2bec6064f11e0635b7297ac45e32e95b4dc4b5-json.log",
"Name": "/friendly_hertz",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "host",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/7ca38788421e3cd83ce453e8c19d69beee60d2bfc3a63e9e3e967c63ebf01aa7-init/diff:/var/lib/docker/overlay2/44f9616418362989da9f89ff5e4f8914c63ef39bdf25f50bcd5196b899d1207a/diff:/var/lib/docker/overlay2/52d12923e4121de738b5dffcd07781ed1b098bbcc45edb45fb274ce264b31cb9/diff:/var/lib/docker/overlay2/7f0afaafca4249a84e037766cd95f2c9fb8513404a6d587f6c39aaabf97d6a50/diff:/var/lib/docker/overlay2/cab741e843ce2f6c4eb6993a8cca9c5e189a6ddacc40d4ce00f3820596f25a93/diff:/var/lib/docker/overlay2/c49b09f1837aa507bbcc1829ca1eb29f81b2f7741ffdbdc0251eff65f4a2e409/diff:/var/lib/docker/overlay2/d7004feef233672b40d666ff5eecd77222ce017145e0d1c4e211fc7f29127001/diff",
"MergedDir": "/var/lib/docker/overlay2/7ca38788421e3cd83ce453e8c19d69beee60d2bfc3a63e9e3e967c63ebf01aa7/merged",
"UpperDir": "/var/lib/docker/overlay2/7ca38788421e3cd83ce453e8c19d69beee60d2bfc3a63e9e3e967c63ebf01aa7/diff",
"WorkDir": "/var/lib/docker/overlay2/7ca38788421e3cd83ce453e8c19d69beee60d2bfc3a63e9e3e967c63ebf01aa7/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "c41436dfd54e",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"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.21.4",
"NJS_VERSION=0.7.0",
"PKG_RELEASE=1~bullseye"
],
"Cmd": [
"nginx",
"-g",
"daemon off;"
],
"Image": "nginx",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"/docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
},
"StopSignal": "SIGQUIT"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "51e357b0d3ee94509d349b0b1dc9584af9b72cb5c35bb5cfbe6c95d0a8d0bf19",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": null
},
"SandboxKey": "/var/run/docker/netns/51e357b0d3ee",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "7d77c3930747384ce38f101b3791df8fe0e4e0b1011d298a32bf74957852e8e8",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "5a9bb6a9d1591969d65d419b3332d10aed95c6f09835223a733f2042c4bae0d2",
"EndpointID": "7d77c3930747384ce38f101b3791df8fe0e4e0b1011d298a32bf74957852e8e8",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]
docker event state
可能出现的错误与解决办法
启动(重启)服务时显示
解决办法:
这个原因是因为创建了/etc/docker/daemon.json文件,也就是docker镜像加速文件,解决方法有两个:
- 只需要将自己的docker镜像加速地址按照前面的方法写入重载一遍配置文件即可。
- 不创建/etc/docker/daemon.json文件,但不好的一点是,无法使用镜像加速,拉取镜像时会很耗时间。所以建议使用第一个解决办法
安装docker-ce时显示
解决办法:
这个问题的原因即可能是因为依赖的原因,要解决这个问题只需要根据提示在安装时后面加上--allowerasing
即可
评论区