Subscribed unsubscribe Subscribe Subscribe

@peccul is peccu

(love peccu '(emacs lisp cat outdoor bicycle mac linux coffee))

dockerをアップデートすると起動しなくなった (CentOS 7 docker 1.5)

yum updateしてdockerのバージョンが1.5になりました。

systemdでリスタートすると起動に失敗しました。

$ sudo systemctl start -l docker
Failed to issue method call: Unit docker.socket failed to load: No such file or directory.
$ sudo systemctl status -l docker
docker.service - Docker Application Container Engine
   Loaded: loaded (/etc/systemd/system/docker.service; enabled)
   Active: failed (Result: resources) since Thu 2015-04-16 21:28:00 JST; 10s ago
     Docs: http://docs.docker.io
 Main PID: 9437

Apr 16 21:27:59 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Apr 16 21:27:59 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Apr 16 21:28:00 localhost.localdomain systemd[1]: docker.service holdoff time over, scheduling restart.
Apr 16 21:28:00 localhost.localdomain systemd[1]: docker.service failed to schedule restart job: Unit docker.socket failed to load: No such file or directory.
Apr 16 21:28:00 localhost.localdomain systemd[1]: Unit docker.service entered failed state.

systemdの設定にはシステムの設定/usr/lib/systemd/system/docker.serviceと、過去に手を加えた修正後の設定/etc/systemd/system/docker.serviceがありました。

後者にプロキシの設定を追加していたのですが、 dockerのアップデートでdocker.socketへの依存がなくなったのでシステムの設定は更新されていたのに対し、 修正後のせってにはそのための記述が残っているのが原因でした。

  • 誤りの設定(/etc/systemd/system/docker.service)
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.io
After=network.target
Requires=docker.socket

[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
Environment="HTTP_PROXY=http://proxy:8080"
ExecStart=/usr/bin/docker -d $OPTIONS $DOCKER_STORAGE_OPTIONS
Restart=on-failure
LimitNOFILE=1048576
LimitNPROC=1048576

[Install]
Also=docker.socket
WantedBy=multi-user.target
  • 正しい設定

Alsoの設定などはここをちらっと見ました。

systemd.unit

[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.io
After=network.target

[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment="HTTP_PROXY=http://proxy:8080"
ExecStart=/usr/bin/docker -d $OPTIONS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $ADD_REGISTRY \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
MountFlags=slave

[Install]
WantedBy=multi-user.target

再度システムの設定を複製し、プロキシの設定を追加しなおすと起動しました。

設定の読み込み直しと、dockerの開始です。

$ sudo systemctl status -l docker
...
Warning: Unit file changed on disk, 'systemctl daemon-reload' recommended.
$ sudo systemctl daemon-reload
$ sudo systemctl start docker
$ sudo systemctl status -l docker
docker.service - Docker Application Container Engine
   Loaded: loaded (/etc/systemd/system/docker.service; enabled)
   Active: active (running) since Thu 2015-04-16 21:34:19 JST; 52s ago
     Docs: http://docs.docker.io
 Main PID: 10769 (docker)
   CGroup: /system.slice/docker.service
           `-10769 /usr/bin/docker -d --selinux-enabled

Apr 16 21:33:29 localhost.localdomain docker[10769]: time="2015-04-16T21:33:29+09:00" level="info" msg="+job serveapi(unix:///var/run/docker.sock)"
Apr 16 21:33:29 localhost.localdomain docker[10769]: time="2015-04-16T21:33:29+09:00" level="info" msg="Listening for HTTP on unix (/var/run/docker.sock)"
Apr 16 21:34:13 localhost.localdomain docker[10769]: time="2015-04-16T21:34:13+09:00" level="info" msg="+job init_networkdriver()"
Apr 16 21:34:18 localhost.localdomain docker[10769]: time="2015-04-16T21:34:18+09:00" level="info" msg="-job init_networkdriver() = OK (0)"
Apr 16 21:34:19 localhost.localdomain docker[10769]: time="2015-04-16T21:34:19+09:00" level="info" msg="Loading containers: start."
Apr 16 21:34:19 localhost.localdomain docker[10769]: time="2015-04-16T21:34:19+09:00" level="info" msg="Loading containers: done."
Apr 16 21:34:19 localhost.localdomain docker[10769]: time="2015-04-16T21:34:19+09:00" level="info" msg="docker daemon: 1.5.0-dev fc0329b/1.5.0; execdriver: native-0.2; graphdriver: devicemapper"
Apr 16 21:34:19 localhost.localdomain docker[10769]: time="2015-04-16T21:34:19+09:00" level="info" msg="+job acceptconnections()"
Apr 16 21:34:19 localhost.localdomain docker[10769]: time="2015-04-16T21:34:19+09:00" level="info" msg="-job acceptconnections() = OK (0)"
Apr 16 21:34:19 localhost.localdomain systemd[1]: Started Docker Application Container Engine.