Docker是一种C/S结构,所以就会有客户端和服务端。Docker支持很多子命令,例如我们在命令行docker然后tab键会出来很多命令
当然docker工具很多,除了 docker 命令行工具,用户也可以通过 REST API 与服务器通信
Docker daemon是服务器组件,以 Linux 后台服务的方式运行。可以通过命令:systemctl status docker.service看到
Docker daemon 运行在 Docker host 上,负责创建、运行、监控容器,构建、存储镜像。
监听地址的配置:
默认docker daemon只能监听本地host,如果远程要访问,需要打开tcp监听,如下:
1
|
/etc/systemd/system/multi-user .target.wants /docker .service
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
[Unit] Description=Docker Application Container Engine Documentation=https: //docs .docker.com
After=network.target docker.socket firewalld.service Requires=docker.socket [Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker ExecStart= /usr/bin/dockerd -H fd: //
#上面这里如果改成这样就开启了监听远程所有端口:ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0 ExecReload= /bin/kill -s HUP $MAINPID
LimitNOFILE=1048576 # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNPROC=infinity LimitCORE=infinity # Uncomment TasksMax if your systemd version supports it. # Only systemd 226 and above support this version. TasksMax=infinity TimeoutStartSec=0 # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate= yes
# kill only the docker process, not all processes in the cgroup KillMode=process [Install] WantedBy=multi-user.target |
重启服务端docker
1
2
|
systemctl daemon-reload systemctl restart docker.service |
调试
可以通过在客户端通过H参数来指定服务器和info子命令来查看服务端信息
这里可以看到哦啊服务端运行情况
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
root@d1: /etc/apt # docker -H 192.168.56.132 info
Containers: 1 Running: 0
Paused: 0
Stopped: 1
Images: 1 Server Version: 17.03.1-ce Storage Driver: aufs Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 9
Dirperm1 Supported: true
Logging Driver: json- file
Cgroup Driver: cgroupfs Plugins: Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe init version: 949e6fa Security Options: apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-31-generic Operating System: Ubuntu 16.04.1 LTS OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 3.842 GiB Name: d1 ID: SQ7Y:TBJA:LS5G:IQNB:CIHC:6T2D:J22X:F3QK:7AS2:7KLN:NIIQ:JLXY Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https: //index .docker.io /v1/
WARNING: No swap limit support Experimental: false
Insecure Registries: 127.0.0.0 /8
Registry Mirrors: http: //febb9aec .m.daocloud.io
Live Restore Enabled: false
|
本文转自 kesungang 51CTO博客,原文链接:http://blog.51cto.com/sgk2011/1923361,如需转载请自行联系原作者