4
0

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 3 years have passed since last update.

GitHub Actions docker-compose exec で the input device is not a TTY エラー

Last updated at Posted at 2021-05-20

GitHub Actionsでdocker-composeでコンテナ内にあるLaravelのartisanコマンドを実行させたい時にエラーになったので解決方法を残します。

環境

  • Ubuntu: 20.04.2 LTS (Focal Fossa)
  • Docker Client: 20.10.6+azure
  • Docker Server Engine: 20.10.6+azure

.github/workflows/integration-laravel-testing.yml

.github/workflows/integration-laravel-testing.yml
name: Laravel Testing

on:
  pull_request:

jobs:
  laravel-testing:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Docker Version
        run: docker version

      - name: Docker Compose Build and Up
        run: |
          docker-compose build app web db
          docker-compose up -d app web db

      - name: Docker Compose Process
        run: docker-compose ps -a

      - name: PHP, Composer Version
        run: |
          docker-compose exec app php --version
          docker-compose exec app composer --version

実行結果(エラー)

ScreenShot 2021-05-20 10.15.02.png

Run docker-compose exec app php --version
  docker-compose exec app php --version
  docker-compose exec app composer --version
  shell: /usr/bin/bash -e {0}
the input device is not a TTY
Error: Process completed with exit code 1.

the input device is not a TTY は一体なんなんだ...🤔
直訳すると 入力デバイスはTTYではありません

ヘルプ

$ docker-comopse exec -h

    -T                Disable pseudo-tty allocation. By default `docker-compose exec`
                      allocates a TTY.

-T オプションを付けると疑似ttyの割り当てを無効化してくれるみたい。
試しに -T を付けてみる。

      - name: PHP, Composer Version
        run: |
          docker-compose exec -T app php --version
          docker-compose exec -T app composer --version

実行結果(成功)

ScreenShot 2021-05-20 10.20.56.png

調べてみる

COMPOSE_INTERACTIVE_NO_CLI=1 の環境変数を設定しても解決できるみたい

そもそもttyとは?

仮想ファイルで出入力を扱うデバイスらしい。
GitHub Actions上だとttyが割り当てられないのかな?詳しい人教えてください🙏

$ docker run -it ubuntu bash

docker run するときは明示的に --interactive--tty を指定するよね🤔
docker-compose exec の時はデフォルトでttyが割り当てられるっぽい。

よくわかってないけど、とりあえず動くのでヨシ!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?