0
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?

More than 1 year has passed since last update.

Dockerコンテナの起動方法メモ

Posted at

よく忘れるのと詰まったことがあったのでメモ

フォルダ構成

├── build
│   └── Dockerfile
└── docker-compose.yml

コマンド

Dockerコンテナの起動
docker-compose up -d

Dockerコンテナへ入る
docker exec -it hoge-app /bin/bash

トラブルメモ

docker-compose up -dを実行してもコンテナが起動しない

failed to solve: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount2182286999/Dockerfile: no such file or directory

→docker-compose.ymlの設定を見直す
今回の場合はdockerfile:でDockerfileのPathの指定が必要だった。

docker-compose.yml
version: '3'
services:
  hoge-app: # サービス名
    container_name: hoge-app
    build: # ビルドに使うDockerファイルのパス
      context: .
      dockerfile: ./build/Dockerfile ## フォルダ構成でbuildフォルダ配下にDockerfileを配置している場合はこの記載が必要、同じ階層に配置していればいらない。
    ports:
      - 8083:8080
    volumes: # マウントディレクトリ
      - ./:/app
    tty: true # コンテナの永続化
    environment:
      - TZ=Asia/Tokyo
0
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
0
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?