一、Docker是什么?
《Docker开发实践》中讲了个故事:20世纪60年代以前的海运,货物都放置在一起,很容易挤压受损。同时,不同的运输方式之间的转运也很麻烦,例如从码头和火车汽车转运卸货时。不同货物和不同交通工具之间的组合是一个巨大的二维矩阵。海运界最后达成了一致,制定了国际标准集装箱来解决这个棘手的问题。所有货物都打包进集装箱互相隔离,所有交通工具都通过集装箱转运,极大地提供了运输的安全性和效率。
在软件开发中我们也经常碰到同样的问题,使用了各种各样技术框架的应用程序,从前端静态网站到后端数据库,从PHP到Java,以及多种多样的部署环境,从测试服务器到线上环境,从虚拟机到公有云等等。Docker,正是这个集装箱,而Docker的logo也的确是个集装箱。
二、Docker与容器和虚拟机
很自然地我们会问,Docker跟虚拟机有什么区别啊?这个问题可以拆成两部分。因为Docker并不是什么完全独创的技术,而是属于很早便有了的容器技术,所以第一个问题就是容器与虚拟机的区别?同属于容器技术,Docker的兄弟姐妹还有Solaris Zones、BSD jails、LXC等。但Docker现在这么火,自然有它的独到之处,所以第二个问题就是Docker与其他容器的区别?
关于第一个问题比较简单,容器是一种轻量级的虚拟技术。它不像虚拟机那样具有一套完整的CPU、内存和磁盘,对操作系统有绝对的权限。容器和宿主主机共享内核,所有容器共享操作系统,在一台物理机上可以运行成百上千的容器。第二个问题稍麻烦一些,与LXC相比,Docker对配置进行了抽象,使应用在任何平台上的运行环境都一致。同时提供了版本控制、镜像托管等类似Git的现代化设施和生态圈。
总体来看,Docker的应用场景有:
- 加速本地开发:快速搭建好开发环境和运行环境
- 自动打包和部署应用
- 创建轻量级的私有Paas环境
- 自动化测试和持续集成
- 创建安全沙盒
三、OCI&OCF
3.1 OCI
Open Container-initiative(开源的容器的一个建议或倡导)
3.2 OCF
开源的容器的格式 runC是一个命令行工具,是用于根据OCI规范生成和运行容器
- 容器作为runC的子进程启动,可以嵌入到各种其他系统中,而无需运行守护进程
- runC构建在libcontainer上,这项容器技术为数百万Docker引擎安装提供了动力
docker提供了一个专门容纳容器镜像的站点:https://hub.docker.com/
四、docker架构
五、docker镜像与镜像仓库
为什么镜像仓库名字是Registry而不是repository?在docker中仓库的名字是以应用的名称取名的。 镜像是静态的,而容器是动态的,容器有其生命周期,镜像与容器的关系类似于程序与进程的关系。镜像类似于文件系统中的程序文件,而容器则类似于将一个程序运行起来的状态,也即进程。所以容器是可以删除的,容器被删除后其镜像是不会被删除的。
六、docker对象
使用docker时,您正在创建和使用图像、容器、网络、卷、插件和其他对象。
-
镜像
- 镜像是只读模板,其中包含创建docker容器的说明。
- 通常,一个镜像基于另一个镜像,并进行一些额外的自定义。
- 您可以创建自己的镜像,也可以只使用其他人创建并在registry中发布的镜像。
-
容器
- conntainer是镜像的可运行实例。 您可以使用docker API或CLI创建、运行、停止、移动或删除容器。
- 您可以将容器连接到一个或多个网络,将存储连接到容器,甚至可以基于其当前状态创建新镜像。
七、安装及使用docker
7.1 docker安装
环境:centos 7.5
[root@localhost ~]
[root@localhost yum.repos.d]
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo
CentOS-Debuginfo.repo CentOS-Sources.repo
[root@localhost yum.repos.d]
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:-100 1919 100 1919 0 0 3806 0 --:--:-- --:--:-- --:--:-- 3815
[root@localhost yum.repos.d]
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo docker-ce.repo
CentOS-Debuginfo.repo CentOS-Sources.repo
[root@localhost yum.repos.d]
[root@localhost yum.repos.d]
[root@localhost yum.repos.d]
[root@localhost ~]
7.2 docker加速
docker-ce的配置文件是/etc/docker/daemon.json,此文件默认不存在,需要我们手动创建并进行配置,而docker的加速就是通过配置此文件来实现的。
docker的加速有多种方式:
[root@localhost ~]
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]
key.json
[root@localhost ~]
> {
> "registry-mirrors": ["https://2bkybiwf.mirror.aliyuncs.com"]
> }
> EOF
{
"registry-mirrors": ["https://2bkybiwf.mirror.aliyuncs.com"]
}
[root@localhost ~]
{
"registry-mirrors": ["https://2bkybiwf.mirror.aliyuncs.com"]
}
[root@localhost ~]
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: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
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: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.779GiB
Name: localhost.localdomain
ID: BYNG:CDGP:V62W:5NS4:CQPZ:ZCHU:N2YY:DMF6:CDVT:WMOJ:ZQW4:D7IP
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
Live Restore Enabled: false
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
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: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
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: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
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: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.779GiB
Name: localhost.localdomain
ID: BYNG:CDGP:V62W:5NS4:CQPZ:ZCHU:N2YY:DMF6:CDVT:WMOJ:ZQW4:D7IP
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://2bkybiwf.mirror.aliyuncs.com/ 重启之后,这里就会有一个加速器
Live Restore Enabled: false
[root@localhost ~]
Client: Docker Engine - Community
Version: 20.10.11
API version: 1.41
Go version: go1.16.9
Git commit: dea9396
Built: Thu Nov 18 00:38:53 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.11
API version: 1.41 (minimum version 1.12)
Go version: go1.16.9
Git commit: 847da18
Built: Thu Nov 18 00:37:17 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.12
GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0
7.3 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 → 从registry中拉取一个镜像或仓库
[root@localhost ~]# docker pull nginx:1.20.2
1.20.2: Pulling from library/nginx
eff15d958d66: Pull complete
1f3e1e3ef6aa: Pull complete
231009cab23f: Pull complete
b2ef879f0046: Pull complete
5495a7eec709: Pull complete
ddde57a4eac9: Pull complete
Digest: sha256:6ce65dd1f3bf44fa60a0212f0f893b78a706f20f09c884b43de50037067d9f5d
Status: Downloaded newer image for nginx:1.20.2
docker.io/library/nginx:1.20.2
- docker images → 列出镜像的详细信息
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx 1.20.2 aedf7f31bdab 2 weeks ago 141MB
[root@localhost ~]# docker create nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
eff15d958d66: Already exists
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
a2ea3d233157813ee4e6cf4bfdf46aac33d3c8df01a3489607c7d2bc4e52da89
[root@localhost ~]# docker create busybox sleep 3600
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
3aab638df1a9: Pull complete
Digest: sha256:52817dece4cfe26f581c834d27a8e1bcc82194f914afe6d50afad5a101234ef1
Status: Downloaded newer image for busybox:latest
3f3353ebf447da22ea1248e18067e45357d2688e34f411653919e706df116e8d
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3f3353ebf447 busybox "sleep 3600" About a minute ago Created beautiful_driscoll
66565bdd7b1f nginx "/docker-entrypoint.…" 14 minutes ago Exited (137) 6 minutes ago stoic_curie
[root@localhost ~]# docker start 3f3353ebf447
3f3353ebf447
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3f3353ebf447 busybox "sleep 3600" 2 minutes ago Up 55 seconds beautiful_driscoll
[root@localhost ~]# docker ps -a // -a 查看所有容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
66565bdd7b1f nginx "/docker-entrypoint.…" About a minute ago Created stoic_curie
a2ea3d233157 nginx "/docker-entrypoint.…" About a minute ago Created sad_fermi
[root@localhost ~]# docker start 66565bdd7b1f
66565bdd7b1f
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
66565bdd7b1f nginx "/docker-entrypoint.…" 3 minutes ago Up 4 seconds 80/tcp stoic_curie
[root@localhost ~]# docker restart 66565bdd7b1f
66565bdd7b1f
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
66565bdd7b1f nginx "/docker-entrypoint.…" 5 minutes ago Up 6 seconds 80/tcp stoic_curie
[root@localhost ~]# docker stop 66565bdd7b1f
66565bdd7b1f
[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
66565bdd7b1f nginx "/docker-entrypoint.…" 6 minutes ago Exited (0) 17 seconds ago stoic_curie
[root@localhost ~]# docker kill 66565bdd7b1f
66565bdd7b1f
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
66565bdd7b1f nginx "/docker-entrypoint.…" 8 minutes ago Exited (137) 8 seconds ago stoic_curie
[root@localhost ~]# docker run -it busybox /bin/sh // -i 交互模式,可以使用-i进入容器; -t tty 给它一个站的住脚的位置
/ # ls
bin dev etc home proc root sys tmp usr var
/ # pwd
/
[root@localhost ~]# docker run -d httpd // 运行(部署)一个网站
Unable to find image 'httpd:latest' locally
latest: 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:latest
2dd4b4019147f7409a5bb78869a508149c15e6449412323076564df76f1d12d0
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2dd4b4019147 httpd "httpd-foreground" 9 seconds ago Up 8 seconds 80/tcp infallible_thompson
3f3353ebf447 busybox "sleep 3600" 10 minutes ago Up 9 minutes beautiful_driscoll
[root@localhost ~]# docker logs 2dd4b4019147
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
[Wed Dec 01 14:58:17.793554 2021] [mpm_event:notice] [pid 1:tid 139649966746944] AH00489: Apache/2.4.51 (Unix) configured -- resuming normal operations
[Wed Dec 01 14:58:17.793789 2021] [core:notice] [pid 1:tid 139649966746944] AH00094: Command line: 'httpd -D FOREGROUND'
172.17.0.1 - - [01/Dec/2021:15:01:33 +0000] "GET / HTTP/1.1" 200 45
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2dd4b4019147 httpd "httpd-foreground" 5 minutes ago Up 5 minutes 80/tcp infallible_thompson
3f3353ebf447 busybox "sleep 3600" 16 minutes ago Up 14 minutes beautiful_driscoll
[root@localhost ~]# docker rm -f 3f3353ebf447
3f3353ebf447
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2dd4b4019147 httpd "httpd-foreground" 6 minutes ago Up 6 minutes 80/tcp infallible_thompson
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2dd4b4019147 httpd "httpd-foreground" 7 minutes ago Up 7 minutes 80/tcp infallible_thompson
66565bdd7b1f nginx "/docker-entrypoint.…" 30 minutes ago Exited (137) 22 minutes ago stoic_curie
a2ea3d233157 nginx "/docker-entrypoint.…" 30 minutes ago Created sad_fermi
[root@localhost ~]# docker ps -aq
2dd4b4019147
66565bdd7b1f
a2ea3d233157
[root@localhost ~]# docker rm $(docker ps -aq)
66565bdd7b1f
a2ea3d233157
Error response from daemon: You cannot remove a running container 2dd4b4019147f7409a5bb78869a508149c15e6449412323076564df76f1d12d0. Stop the container before attempting removal or force remove
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2dd4b4019147 httpd "httpd-foreground" 8 minutes ago Up 8 minutes 80/tcp infallible_thompson
- docker attach → 连接到正在运行的容器上(进到容器里面后不能做任何事,必须按ctrl+c才能退出,但是ctrl+c退出后,容器也退出了,所以这种方式平时不会用到)
[root@localhost ~]# docker attach 2dd4b4019147
ls
quit
^C[Wed Dec 01 15:09:01.018352 2021] [mpm_event:notice] [pid 1:tid 139649966746944] AH00491: caught SIGTERM, shutting down
- docker exec → 在正在运行的容器中运行命令(exec必须用交互模式进入容器,用exit退出后,容器依然会运行)
[root@localhost ~]# docker exec -it 2dd4b4019147 /bin/bash
root@2dd4b4019147:/usr/local/apache2# exit
exit
[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: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
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: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.779GiB
Name: localhost.localdomain
ID: BYNG:CDGP:V62W:5NS4:CQPZ:ZCHU:N2YY:DMF6:CDVT:WMOJ:ZQW4:D7IP
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
Live Restore Enabled: false
- docker inspect → 返回有关Docker对象的详细信息
[root@localhost ~]# docker inspect 2dd4b4019147
[
{
"Id": "2dd4b4019147f7409a5bb78869a508149c15e6449412323076564df76f1d12d0",
"Created": "2021-12-01T14:58:17.480606425Z",
"Path": "httpd-foreground",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 40723,
"ExitCode": 0,
"Error": "",
"StartedAt": "2021-12-01T14:58:17.767659939Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:ad17c88403e2cedd27963b98be7f04bd3f903dfa7490586de397d0404424936d",
"ResolvConfPath": "/var/lib/docker/containers/2dd4b4019147f7409a5bb78869a508149c15e6449412323076564df76f1d12d0/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/2dd4b4019147f7409a5bb78869a508149c15e6449412323076564df76f1d12d0/hostname",
"HostsPath": "/var/lib/docker/containers/2dd4b4019147f7409a5bb78869a508149c15e6449412323076564df76f1d12d0/hosts",
"LogPath": "/var/lib/docker/containers/2dd4b4019147f7409a5bb78869a508149c15e6449412323076564df76f1d12d0/2dd4b4019147f7409a5bb78869a508149c15e6449412323076564df76f1d12d0-json.log",
"Name": "/infallible_thompson",
"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/59806da4fa41ad1fabf77b620307211cd490f177e1ce9e593084ca01a06a12c2-init/diff:/var/lib/docker/overlay2/36ed93e176c0efdde307d3bc1d79afde06b98ce5d55e8a5559f9d52898fa700f/diff:/var/lib/docker/overlay2/da05fe4a138adfa74195fbe6b7d48a1e33b7bdef9991dc56f0d41c9dce0dee6c/diff:/var/lib/docker/overlay2/9c7068052b46318736e32d7e970398f0fe7df8a749201bcf60c692f410cba13d/diff:/var/lib/docker/overlay2/1953bf937cd0997d8b717ca69f3c0384de3497ff7292af506c90eb4d371ad2d0/diff:/var/lib/docker/overlay2/c69f8634857d44cd89525b782bd5c39014984e753f7ebc5b6c3e661577c87b3b/diff",
"MergedDir": "/var/lib/docker/overlay2/59806da4fa41ad1fabf77b620307211cd490f177e1ce9e593084ca01a06a12c2/merged",
"UpperDir": "/var/lib/docker/overlay2/59806da4fa41ad1fabf77b620307211cd490f177e1ce9e593084ca01a06a12c2/diff",
"WorkDir": "/var/lib/docker/overlay2/59806da4fa41ad1fabf77b620307211cd490f177e1ce9e593084ca01a06a12c2/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "2dd4b4019147",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/apache2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"HTTPD_PREFIX=/usr/local/apache2",
"HTTPD_VERSION=2.4.51",
"HTTPD_SHA256=20e01d81fecf077690a4439e3969a9b22a09a8d43c525356e863407741b838f4",
"HTTPD_PATCHES="
],
"Cmd": [
"httpd-foreground"
],
"Image": "httpd",
"Volumes": null,
"WorkingDir": "/usr/local/apache2",
"Entrypoint": null,
"OnBuild": null,
"Labels": {},
"StopSignal": "SIGWINCH"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "08e39e54dcab30e7d01e8dd0c9d69668a39e2afab86cd846fad09e217fbb8b50",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": null
},
"SandboxKey": "/var/run/docker/netns/08e39e54dcab",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "15b1dcd50fb8583744379ec7a65a6bbccf8e4fe76c81ef57ebdf36e817395f6f",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:04",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "1e342ac6b2af20d51aa467e89ce0d41f754e4daca47beb34de0a6c0de81750d2",
"EndpointID": "15b1dcd50fb8583744379ec7a65a6bbccf8e4fe76c81ef57ebdf36e817395f6f",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:04",
"DriverOpts": null
}
}
}
}
]
[root@localhost ~]# curl 172.17.0.4
<html><body><h1>It works!</h1></body></html>
八、docker事件状态
|