はじめに
ConoHa VPS内で起動しているDockerコンテナに接続できなくなることがあり、日次cronでDockerを再起動することで回避したので、記載しておきます。
2016/2/2 追記
VPSをCentOS7で作成し、新しいバージョンのDockerを利用した際にコンテナが無反応になる現象を回避することができました。
再起動シェルの配置
シェル内容
docker-restart.sh
#!/bin/bash
CHECK_PS=(`docker ps -q`)
for list in ${CHECK_PS[@]}
do
docker stop ${list}
if [ $? != 0 ];
then
exit 1;
fi
done
/etc/rc.d/init.d/docker restart
if [ $? != 0 ];
then
exit 1;
fi
for list in ${CHECK_PS[@]}
do
docker start ${list}
if [ $? != 0 ];
then
exit 1;
fi
done
exit 0
動作概要
直前まで起動していたコンテナを記憶し、Docker再起動後に該当のコンテナを復活させます。
あとがき
Dockerのコンテナが利用不能になってしまう原因が追えていない為、原因が判明したらそちらへの対処をしたいです。