Command execution in a script running on Docker fails

Using the video here, had setup a project on PHPStorm using Docker. 

docker-compose.yml

version: '2'
services:
webserver:
image: phpstorm/php-56-apache-xdebug-25
ports:
- "80:80"
volumes:
- ./:/var/www/html
environment:
XDEBUG_CONFIG: remote_host=host.docker.internal

Installed additional package in the container:

apt install libswe-dev

PHP Script:

<?php
$command = "/usr/bin/swetest -b15.08.1947 -ut04:47:00 -p0142536m -house11.09,79.6,a -sid1 -fPlbsad -g, -head";
exec($command, $out);
print_r($out);

 

When running directly from command line of container, this is the output:

Array
(
    [0] => Sun            , 118.4008085,  0.0000333,  0.9610991, 143.9051592, 14.3324527
    [1] => Moon           , 100.4573693,  4.5364404, 15.1263687, 127.0491683, 23.7657463
    [2] => Mars           , 67.7379705,  0.2542660,  0.6571849, 90.9429029, 23.6975336
    [3] => Mercury        , 104.4522140,  0.8449540,  1.8261036, 130.2164091, 19.1978117
    [4] => Jupiter        , 205.9145172,  0.8493031,  0.0865064, 226.8263332,-16.6687815
    [5] => Venus          , 113.0904476,  1.1248585,  1.2352381, 139.0263664, 17.0539399
    [6] => Saturn         , 110.5278046,  0.7520275,  0.1277785, 136.3472282, 17.4515590
    [7] => mean Node      , 35.0470575,  0.0000000, -0.0529538, 55.9196515, 19.7587082
    [8] => house  1       , 142.9593939, 145.3029493, 13.8675938
    [9] => house  2       , 172.9593939, 173.5355640,  2.7954234
    [10] => house  3       , 202.9593939, 201.2391560, -8.9287945
    [11] => house  4       , 232.9593939, 230.5598854,-18.5176142
    [12] => house  5       , 262.9593939, 262.3330009,-23.2588547
    [13] => house  6       , 292.9593939, 294.7858077,-21.4916832
    [14] => house  7       , 322.9593939, 325.3029493,-13.8675938
    [15] => house  8       , 352.9593939, 353.5355640, -2.7954234
    [16] => house  9       , 22.9593939, 21.2391560,  8.9287945
    [17] => house 10       , 52.9593939, 50.5598854, 18.5176142
    [18] => house 11       , 82.9593939, 82.3330009, 23.2588547
    [19] => house 12       , 112.9593939, 114.7858077, 21.4916832
    [20] => Ascendant      , 142.9593939, 145.3029493, 13.8675938
    [21] => MC             , 24.9370136, 23.1021092,  9.6574553
    [22] => ARMC           , 45.5956163, 43.1282965, 16.5144675
    [23] => Vertex         , 286.6498188, 288.0546257,-22.4082962
)

 

When running from PHPStorm, this is the output:

[docker://phpstorm/php-56-apache-xdebug-25:latest/]:php /opt/project/debug.php
sh: 1: /usr/bin/swetest: not found
Array
(
)

Most likely it is the package installation that is leading to this, probably something needs to be refreshed in PHPStorm?

Looking forward to getting this working.

Thanks!

1
6 comments

Updated files to install the package in the container by default.

Dockerfile

FROM phpstorm/php-56-apache-xdebug-25

RUN apt update \
&& apt install -y libswe-dev

 

docker-compose.yml

version: '2'
services:
webserver:
build:
context: .
image: astrology/calculation
ports:
- "80:80"
volumes:
- ./:/var/www/html
environment:
XDEBUG_CONFIG: remote_host=host.docker.internal

 

The error persists.

[docker://phpstorm/php-56-apache-xdebug-25:latest/]:php /opt/project/debug.php
sh: 1: /usr/bin/swetest: not found
Array
(
)
0

@...

That's interesting to know. Did not have to do much to get this setup up and running. Can you share the steps you took to resolve this issue? If not, let's wait for the Jetbrains/PHPStorm team to respond with a solution.

 

0

Sorry, it took some time to respond. Basically, I was not able to reproduce the issue with your configuration on my side:

What lifecycle option do you have in the PHP CLI Interpreter settings? Would it be possible to temporarily switch it to "run" (if not yet) and check if it helps?

 

1

Vasiliy Yur

No problem about the delay - happens occasionally to the best of us.

Couldn't find the lifecycle option. On further investigation realized that when creating a PHP CLI interpreter, docker-compose should be chosen and not docker to get the Lifecycle management options. 

However, when creating a PHP interpreter, choosing the docker-compose option, the PHP executable is not found. Added more details here.

Looking forward to your assistance in resolving this.

Thanks!

0

Understanding from the JB team that filing a bug is more appropriate, created a bug report here. Vasiliy Yur hoping that this is not a problem. 

 

0

Thanks for submitting the YouTrack ticket!

Just in case, I will repeat myself here. Could you please try to disable the Docker Compose V2 option (if you have it already) and check if it helps?

1

Please sign in to leave a comment.