[Docker] agettyのCPU使用率が高い

このブログをDockerのコンテナ(Centos7)に移設して2日くらい経って、
Dockerのホストサーバ(CentOS7)のCPU使用率が高くなっている事に気付いた。

tanker_util_160523

top - 18:28:32 up 2 days, 47 min, 5 users, load average: 0.99, 1.02, 1.08
%Cpu(s): 12.0 us, 38.5 sy, 0.0 ni, 49.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 32818248 total, 11518944 free, 17437140 used, 3862164 buff/cache
KiB Swap: 511676 total, 511676 free, 0 used. 13301472 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5822 root 20 0 8028 836 716 R 100.0 0.0 2925:31 agetty

ホストサーバからtopコマンドで確認したら、agettyのCPU使用率が異様に高くなっていた。
調べるとdockerのバグ?の模様。

Bug 1046469 – docker privileged mode with cmd /sbin/init – agetty & high cpu

docker runで–privileged, /sbin/initしてると発生するみたい。
解決方法としては、対象のコンテナにログインして、
agetty.targetとsystemd-udevd.serviceを停止,自動起動無効にする。
これで暴走しなくなった。

コンテナにログイン
# docker exec -it [container name] /bin/bash

agettyの状態確認、停止、自動起動無効化
# systemctl status agetty.target
# systemctl stop agetty.target
# systemctl disable agetty.target
# systemctl status agetty.target

systemd-udevdの状態確認、停止、自動起動無効化
# systemctl status systemd-udevd.service
# systemctl stop systemd-udevd.service
# systemctl disable systemd-udevd.service
# systemctl status systemd-udevd.service

で最後にコンテナの停止/開始

# docker stop [container name]
# docker start [container name]

Leave a Reply

Your email address will not be published. Required fields are marked *