docker エラー

この記事は1年以上前に書かれたものです。 情報が古い可能性があります。

こんなエラーが出た.

[!!!!!!] Failed to mount API filesystems, freezing.

なんかヤバそうなエラー!
!めっちゃついてるし(笑)
現場で見たら発狂もの?かもしれんけど所詮自宅サーバなので笑う余裕がある.

とりあえずググったけど英語ばっかり出てきましたね.
一応状況書いとくと,

docker on Ubuntu server 16.04 LTS
Docker version 17.05.0-ce, build 89658be

の環境で postfix のサーバ立てようと run したところで発生.
# docker run -it -h mail –name postfix centos:latest /sbin/init

dokcer ps では問題なく起動しているし,docker exec でも問題なく入れた.
ただおそらく systemctl 使うために /sbin/init で起動してるので,この辺の読み込みとかがおかしいと予想(適当).
さらに不思議なことに全く同じコマンドでもこれ出るときとでない時があったりなかったり.

で何だろうと思って英語サイトを必死で漁ること 30 分.

何でことない単純な問題.結論から言うと,

–privileged をつけていなかっただけ.

試しにいくつか無駄にコンテナ立てて見たけど,/sbin/init を centos7 で付ける場合,このオプションがいるような感じ.

debian ではもちろんいらなかったし,–privileged をつけると起こらない模様.

https://github.com/moby/moby/issues/25290での議論によると,

systemd requires certain privileges to run, which are blocked by default in a container for security. To run systemd, you need to allow SYS_ADMIN capabilities, and disable seccomp (or use a custom profile). See the discussion on docker#22285 with more information.

This is not a bug, but by design: processes inside the container should not automatically get these privileges, as they make the container less secure; if a process (such as systemd) requires these privileges, you need to pass them at runtime.

systemd は起動するのに privileges が必要で,コンテナ内においてはセキュリティのためにデフォルトでブロックされている.起動するためには SYS_ADMIN 権限が必要とのこと.

docker の仕組みまで調べるとなると大変なので今後の課題としてちょこちょこ勉強していきたいかな.
あと Debian 系に慣れてしまってるので,CentOS(特に systemctl の 7 系) はコマンドとか色々違って,なかなか覚えるの大変です(^◇^;).

コメント

タイトルとURLをコピーしました