1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

何も考えずに dockerでは起動するがdocker-compose経由だとコンテナが起動失敗する Exited (255) ERROR 事象に対応する

Last updated at Posted at 2024-12-27

docker だとコンテナが起動するが、docker-compose経由だとdockerのコンテナが起動せずに Exited (255) ERROR が出てしまって起動に失敗するパタンに自分がすごくよく遭遇する。

とりあえず、なにも考えずに以下の様に対応。

  • 起動失敗パタン
version: '3'
services:
  app:
    build:
      context: .
      dockerfile: "Dockerfile"
    image: "app"
    container_name: "app"
    ports:
      - 8001:8001
    command: "/sbin/init"
  • 起動成功
version: '3'
services:
  app:
    build:
      context: .
      dockerfile: "Dockerfile"
    image: "app"
    container_name: "app"
    privileged: true # ここ
    ports:
      - 8001:8001
    command: "/sbin/init"
privileged: true

を付与することで起動する。

一応、注意事項としてprivileged: trueはセキュリティ的にリスクを伴うため、なるべく最小限の権限で動作させる方法を検討するのがよいとのこと。

1
1
0

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?