Port, process, resource usage, log management of Docker operation and maintenance

2. Docker-Linux operation and maintenance

1. Port

Use the netstat command on the registry node to query the listening port number of the warehouse. After the query is complete, use the lsof command (if the command does not exist, install it manually) to query the process using this port number. Submit all the above operation commands and output results to the command line interface in text form.

[root@registry ~]# netstat -ntpl

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      724/sshd           

tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      802/master         

tcp6       0      0 :::5000                 :::*                    LISTEN      21423/docker-proxy 

tcp6       0      0 :::22                   :::*                    LISTEN      724/sshd           

tcp6       0      0 ::1:25                  :::*                    LISTEN      802/master 

[root@registry ~]# lsof  -i:5000

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

exe     21423 root    7u  IPv6 267372      0t0  TCP *:commplex-main (LISTEN)

2. Process

Run the lsof command on the Registry node (manually install it if the command does not exist) to query /usr/bin/docker-current related processes, and query the program executed by the process according to the queried process ID. Submit all the above operation commands and output results to the command line interface in text form.

[root@registry ~]# lsof  /usr/bin/docker-current

COMMAND     PID USER  FD   TYPE DEVICE SIZE/OFF     NODE NAME

docker-cu  1492 root txt    REG  253,1 45797613 16903916 /usr/bin/docker-current

exe       21423 root txt    REG  253,1 45797613 16903916 /usr/bin/docker-current

[root@registry ~]# ps aux |grep 1492

root      1492  0.0  1.9 790336 40752 ?        Ssl  Feb13  31:08 /usr/bin/docker-current daemon --exec-opt native.cgroupdriver=systemd --selinux-enabled --log-driver=journald --add-registry 192.168.200.12:5000 --insecure-registry 192.168.200.12:5000

root     32269  0.0  0.0 112640   956 pts/0    S+   02:34   0:00 grep --color=auto 1492

[root@registry ~]# ps aux |grep 21423

root     21423  0.0  0.8 253880 16520 ?        Sl   Mar03   2:55 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5000 -container-ip 172.17.0.2 -container-port 5000

root     32271  0.0  0.0 112640   960 pts/0    S+   02:34   0:00 grep --color=auto 21423

3. Resource usage

On the registry node, use the netstat command (if the command does not exist, install it manually) to query the PID of the docker image warehouse, and use the top command to query the resource usage of the PID queried in the previous step. Submit all the above operation commands and output results to the command line interface in text form.

[root@registry ~]# netstat -ntpl

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      724/sshd           

tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      802/master         

tcp6       0      0 :::5000                 :::*                    LISTEN      21423/docker-proxy 

tcp6       0      0 :::22                   :::*                    LISTEN      724/sshd           

tcp6       0      0 ::1:25                  :::*                    LISTEN      802/master 

[root@registry ~]# top -p 21423

top - 07:26:24 up 35 days,  3:06,  1 user,  load average: 0.00, 0.01, 0.05

Tasks:   1 total,   0 running,   1 sleeping,   0 stopped,   0 zombie

%Cpu(s):  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st

KiB Mem :  2049396 total,   118648 free,   127892 used,  1802856 buff/cache

KiB Swap:        0 total,        0 free,        0 used.  1721968 avail Mem

PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                    

21423 root      20   0  253880  16520   7592 S  0.0  0.8   2:57.51 exe                                         

4.日志

在registry节点通过docker命令查询dockerregistry容器最后20条日志,将以上所有操作命令和输出结果以文本形式提交到命令行界面。

# docker logs --tail=20 940568599bb2

192.168.200.12 - - [29/Mar/2017:05:35:37 +0000] "GET /v2/ HTTP/1.1" 200 2 "" "docker/1.10.3 go/go1.6.3 git-commit/cb079f6-unsupported kernel/3.10.0-229.el7.x86_64 os/linux arch/amd64"

192.168.200.12 - - [29/Mar/2017:05:35:37 +0000] "GET /v1/search?q=swarm HTTP/1.1" 404 19 "" "docker/1.10.3 go/go1.6.3 git-commit/cb079f6-unsupported kernel/3.10.0-229.el7.x86_64 os/linux arch/amd64"

time="2017-03-29T05:35:49Z" level=info msg="response completed" go.version=go1.6.3 http.request.host="192.168.200.12:5000" http.request.id=7bc96c9d-e3a4-43fe-9f6f-1be0ad4e8fe3 http.request.method=GET http.request.remoteaddr="192.168.200.12:50872" http.request.uri="/v2/" http.request.useragent="docker/1.10.3 go/go1.6.3 git-commit/cb079f6-unsupported kernel/3.10.0-229.el7.x86_64 os/linux arch/amd64" http.response.contenttype="application/json; charset=utf-8" http.response.duration=1.946567ms http.response.status=200 http.response.written=2 instance.id=a5140eb2-63c4-40b1-8c88-24aff334bb6a version=v2.5.1

192.168.200.12 - - [29/Mar/2017:05:35:49 +0000] "GET /v2/ HTTP/1.1" 200 2 "" "docker/1.10.3 go/go1.6.3 git-commit/cb079f6-unsupported kernel/3.10.0-229.el7.x86_64 os/linux arch/amd64"

time="2017-03-29T05:35:49Z" level=error msg="response completed with error" err.code="manifest unknown" err.detail="unknown tag=latest" err.message="manifest unknown" go.version=go1.6.3 http.request.host="192.168.200.12:5000" http.request.id=466b5691-ea02-4b27-af3b-340fc69767a4 http.request.method=GET http.request.remoteaddr="192.168.200.12:50873" http.request.uri="/v2/swarm/manifests/latest" http.request.useragent="docker/1.10.3 go/go1.6.3 git-commit/cb079f6-unsupported kernel/3.10.0-229.el7.x86_64 os/linux arch/amd64" http.response.contenttype="application/json; charset=utf-8" http.response.duration=2.057137ms http.response.status=404 http.response.written=96 instance.id=a5140eb2-63c4-40b1-8c88-24aff334bb6a vars.name=swarm vars.reference=latest version=v2.5.1

192.168.200.12 - - [29/Mar/2017:05:35:49 +0000] "GET /v2/swarm/manifests/latest HTTP/1.1" 404 96 "" "docker/1.10.3 go/go1.6.3 git-commit/cb079f6-unsupported kernel/3.10.0-229.el7.x86_64 os/linux arch/amd64"

192.168.200.12 - - [29/Mar/2017:05:35:49 +0000] "GET /v1/repositories/swarm/images HTTP/1.1" 404 19 "" "docker/1.10.3 go/go1.6.3 git-commit/cb079f6-unsupported kernel/3.10.0-229.el7.x86_64 os/linux arch/amd64"

time="2017-03-29T06:10:09Z" level=info msg="PurgeUploads starting: olderThan=2017-03-22 06:10:09.06177115 +0000 UTC, actuallyDelete=true"

time="2017-03-29T06:10:09Z" level=info msg="Purge uploads finished.  Num deleted=0, num errors=0"

time="2017-03-29T06:10:09Z" level=info msg="Starting upload purge in 24h0m0s" go.version=go1.6.3 instance.id=a5140eb2-63c4-40b1-8c88-24aff334bb6a version=v2.5.1

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324482728&siteId=291194637