I am trying setup and run pocketmine in a windows container. using docker The code executes correctly, but I cannot move the data directory to a volume so that the data can be stored on the host server instead of in the container. To the poketmine software a volume, should look identical to a local directory. I have been able to test both the php packaged for pocketmine versus the latest php.net 7.2 RC and the issue seems to be specific to the pocketmine version of php
Version
PS C:\pocketmine> .\bin\php\php.exe -version
PHP 7.2.0RC2 (cli) (built: Sep 14 2017 11:36:27) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0-dev, Copyright (c) 1998-2017 Zend Technologies
Run a windows docker container with a volume
Docker run -it -v c:\user\pockermine:c:\data pocketmine
bin/php/php.exe pocketmine-no.phar 鈥攄ata c:\data
Expected:
Pocketmine starts up as normal.
actual:
Throws the following error.
Fatal error: Uncaught ErrorException: mkdir(): No such file or directory in phar://C:/pocketmine/pocketmine-MP.phar/src/
pocketmine/PocketMine.php:191
Stack trace:
#0 [internal function]: pocketmine\{closure}(2, 'mkdir(): No suc...', 'phar://C:/pocke...', 191, Array)
#1 phar://C:/pocketmine/pocketmine-MP.phar/src/pocketmine/PocketMine.php(191): mkdir('c:\\data\\', 511, true)
#2 C:\pocketmine\pocketmine-MP.phar(1): require('phar://C:/pocke...')
#3 {main}
thrown in phar://C:/pocketmine/pocketmine-MP.phar/src/pocketmine/PocketMine.php on line 191
PS C:\pocketmine>
I tried to reproduce the error with a simple script. I then ran the script with php 7.2 from php.net and then again with php downloaded from the pocketmine appvayor build.
Here is the script:
$filename = 'c:\data';
if (file_exists($filename)) {
echo "The directory $filename exists";
} else {
echo "The directory $filename does not exist";
}
The results of running this under the official php build:
PHP 7.2.0RC3 (cli) (built: Sep 26 2017 15:24:10) ( NTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0-dev, Copyright (c) 1998-2017 Zend Technologies
PS C:\> .\php\php.exe C:\assets\test.php
The directory c:\data exists
The results of running this under the pocketmine php build.
```
PS C:> .\pocketmine\bin\php\php.exe .\assets\test.php
The directory c:\data does not exist
```
I can't reproduce this on PHP 7.2.0RC3, do I need to be running this inside a container to reproduce?
Yes, this issue seems to be specific to a container, because the volume is a windows symlink.
I have the dockerfiles to create container here.: https://github.com/The-HeX/docker-bluelight-windows/tree/master/phpbug
In the mean time, I have managed to work around this issue by faking out a local mapped drive that points to the symlink directory. https://github.com/The-HeX/docker-bluelight-windows/blob/master/pocketmine/dockerfile#L35 . This solution seems to work in a WindowsServerCore container, but does not work in a NanoServer container, which is a much smaller and lightweight container.
Most helpful comment
Yes, this issue seems to be specific to a container, because the volume is a windows symlink.
I have the dockerfiles to create container here.: https://github.com/The-HeX/docker-bluelight-windows/tree/master/phpbug
In the mean time, I have managed to work around this issue by faking out a local mapped drive that points to the symlink directory. https://github.com/The-HeX/docker-bluelight-windows/blob/master/pocketmine/dockerfile#L35 . This solution seems to work in a WindowsServerCore container, but does not work in a NanoServer container, which is a much smaller and lightweight container.