launchpad icon indicating copy to clipboard operation
launchpad copied to clipboard

Docker Compose v2 - read /dev/stderr: bad file descriptor triggered by proc_open

Open Plopix opened this issue 3 years ago • 3 comments

Q A
Bug report? yes
Feature request? no
BC Break report? no
Environment Mac

Coming from this issue: https://github.com/ezsystems/launchpad/issues/103

I also have read /dev/stderr: bad file descriptor with docker compose v2.

I have debugged and that is coming from proc_open.

I don't really understand how to fix this though. The problem is that somehow docker compose v2 detaches a thread/process or something and proc_open loses track of it.

It works like before for stop, start, etc. but for exec (used by ez enter) somehow something runs in the background, and Symfony Process triggers an exception.

read /dev/stderr: bad file descriptor is displayed by the proc_open

I did a reproducer, when you have a working project with eZ Launchpad

mkdir /tmp/testprocess
cd /tmp/testprocess
composer require symfony/process

Then use/adap this code:

<?PHP
// test.php

include "vendor/autoload.php";

use Symfony\Component\Process\Process;

$command = "<RUN `ez ps c` and copy/paste the string here> exec engine /bin/bash";

$process = Process::fromShellCommandline($command);
$process->setTimeout(2 * 3600);
$process->setTty(true);
$process->mustRun();

Example of $command

PROJECTNETWORKNAME=test PROJECTPORTPREFIX=42 PROJECTCOMPOSEPATH=/System/Volumes/Data/Users/plopix/Projects/Test PROVISIONINGFOLDERNAME=provisioning HOST_COMPOSER_CACHE_DIR=/System/Volumes/Data/Users/plopix/Projects/.composer_cache DEV_UID=501 DEV_GID=33 COMPOSER_CACHE_DIR=/var/www/composer_cache PROJECTMAPPINGFOLDER=/var/www/html/project BLACKFIRE_CLIENT_ID= BLACKFIRE_CLIENT_TOKEN= BLACKFIRE_SERVER_ID= BLACKFIRE_SERVER_TOKEN= DOCKER_HOST= DOCKER_CERT_PATH= DOCKER_TLS_VERIFY= PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin XDEBUG_ENABLED=0 docker-compose -p test -f /Users/plopix/Projects/Test/provisioning/dev/docker-compose.yml -f /Users/plopix/Projects/Test/provisioning/dev/docker-compose-osx.yml exec engine /bin/bash

This is ez ps c + exec engine /bin/bash

Run php test.php and see that is working => you get access to the container Change the Docker Compose version to version 2 => see the error.

Any ideas are welcome! ping @YohannsMonnier @bdunogier @lserwatka @SylvainGuittard @florianalexandre @amine-betari @yhanini @anaelChardan @kmadejski @hubformation @sklimaszewski

There is probably a simple trick, and experts of proc_open (and related) might see the problem easily here.

Plopix avatar Dec 29 '21 00:12 Plopix