自动创建Laravel项目失败并出现错误:TTY模式要求/ dev / tty可读/可写

时间:2019-04-17 10:10:04

标签: php laravel docker

这是命令的输出:

Step 5/7 : RUN ./vendor/bin/laravel new --force testapp
 ---> Running in dc92e378b12a
Crafting application...
[91m
[0m[91mIn Process.php line 1062:

  TTY mode requires /dev/tty to be read/writable.


new [--dev] [--force] [--] [<name>]

[0mService 'cli' failed to build: The command '/bin/sh -c ./vendor/bin/laravel new --force testapp' returned a non-zero code: 1
[Pipeline] }

这是我的Docker文件:

$ cat Dockerfile.cli
FROM php:7.2-cli

COPY composer.json /app/
COPY scripts /app/scripts
RUN composer install --no-dev
RUN ./vendor/bin/laravel new --force testapp

# Define where the Drupal Root is located
ENV WEBROOT=web

如何自动构建带有一组特定软件包的Laravel映像进行测试?

2 个答案:

答案 0 :(得分:0)

我发现唯一可行的解​​决方案是放弃laravel命令,并使用composer执行此操作:

RUN composer create-project --prefer-dist laravel/laravel testapp

答案 1 :(得分:0)

运行之前

RUN ./vendor/bin/laravel new --force testapp

包括此行:

RUN sed -i "s/\$process->setTty(true);/\/\/\$process->setTty(true);/g" ./vendor/laravel/installer/src/NewCommand.php

使Dockerfile看起来像这样

FROM php:7.2-cli

COPY composer.json /app/
COPY scripts /app/scripts
RUN composer install --no-dev
RUN sed -i "s/\$process->setTty(true);/\/\/\$process->setTty(true);/g" ./vendor/laravel/installer/src/NewCommand.php
RUN ./vendor/bin/laravel new --force testapp

# Define where the Drupal Root is located
ENV WEBROOT=web