LoginSignup
17
12

More than 5 years have passed since last update.

oci runtime errorでdockerが起動しなくなった件

Last updated at Posted at 2017-11-13

AWS EC2上で起動させていたコンテナがリソース不足で応答不能になったので、
EC2停止 -> スケールアップ -> EC2起動
したら、コンテナが起動しなくなってしまった。

$ docker-compose ps
        Name                      Command                State     Ports
------------------------------------------------------------------------
ec2user_gitlab_1       /sbin/entrypoint.sh app:start    Exit 255
ec2user_postgresql_1   /sbin/entrypoint.sh              Exit 255
ec2user_redis_1        /sbin/entrypoint.sh --logl ...   Exit 255


$ docker-compose up -d
Starting ec2user_postgresql_1 ...
Starting ec2user_redis_1 ...
Starting ec2user_postgresql_1
Starting ec2user_postgresql_1 ... error

ERROR: for ec2user_postgresql_1  Cannot start service postgresql: oci runtime error: container with id exists: 6b69a34b1f5b140bc5b8Starting ec2user_redis_1 ... error

ERROR: for ec2user_redis_1  Cannot start service redis: oci runtime error: container with id exists: fdef8901e8a94418b4cca0fb3eaa7851128cff85eda0e622e7ed9fd013707516

ERROR: for redis  Cannot start service redis: oci runtime error: container with id exists: fdef8901e8a94418b4cca0fb3eaa7851128cff85eda0e622e7ed9fd013707516

ERROR: for postgresql  Cannot start service postgresql: oci runtime error: container with id exists: 6b69a34b1f5b140bc5b889644d117d53fd1840d96879d80ffbdc6284f7ec0305
ERROR: Encountered errors while bringing up the project.

$ docker logs <container id>
   :
   :
container with id exists: <container id>

dockerやEC2を再起動しても解決しなかったが、以下の手順で復活できました。

$ sudo su -
# cd /run/runc/
# ls 
<container id1> <container id2> <container id3>
# rm -fr *

$ docker-compose up -d
Starting ec2user_postgresql_1 ...
Starting ec2user_redis_1 ...
Starting ec2user_postgresql_1
Starting ec2user_redis_1 ... done
Starting ec2user_gitlab_1 ...
Starting ec2user_gitlab_1 ... done

$ docker-compose ps
        Name                      Command               State                           Ports
---------------------------------------------------------------------------------------------------------------------
ec2user_gitlab_1       /sbin/entrypoint.sh app:start    Up      0.0.0.0:10022->22/tcp, 443/tcp, 0.0.0.0:10080->80/tcp
ec2user_postgresql_1   /sbin/entrypoint.sh              Up      5432/tcp
ec2user_redis_1        /sbin/entrypoint.sh --logl ...   Up      6379/tcp

めでたしめでたし。

今まで何度も同じEC2インスタンスを停止->再開していても問題はありませんでした。
今回のような問題に遭遇したのは初めてでしたが、EC2の停止にだいぶ時間がかかっており、少し怪しい気配は感じていました。

削除した /run/runc/<container id>/ には state.json というファイルが存在していて、サイズは25Kほどありcontainerの状態を保持しているようでした。
コンテナを停止するとディレクトリごと消える為、サーバが異常終了し、このファイルが残ってしまった事が原因のようでした。

17
12
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
12