plesk/docker

Creating a container with a domain

Closed this issue · 2 comments

I'm trying to create a container based on the Plesk docker image, as our code base is heavily dependent on Plesk. I get an error when I try to call "plesk bin subscription --create" in my docker file :

FROM plesk/plesk:latest

# setup environment
RUN plesk bin subscription --create mydomain.local \
    -service-plan "Default Domain" \
    -ip 172.17.0.2 \
    -login myuser \
    -passwd "supers3cret"
DB query failed: SQLSTATE[HY000] [2002] No such file or directory

exit status 1

If I use a fresh Plesk container and execute it from the terminal within the container, it yields a few errors but seems to work :

root@d2313bc16ebf:/# plesk bin subscription --create mydomain.local -service-plan "Default Domain" -ip 172.17.0.2 -login myuser -passwd "supers3cret"
SUCCESS: Creation of domain 'mydomain.local' completed.
[2020-06-08 20:03:40.337] ERR [util_exec] proc_close() failed ['/opt/psa/admin/bin/phpinimng' '--type' 'fpm' '--service' 'plesk-php73-fpm' '--poold' '/opt/plesk/php/7.3/etc/php-fpm.d' '--restart'] with exit code [1] 
[2020-06-08 20:03:40.873] ERR [panel] Remove PHP-FPM config for mydomain.local due to service failure: phpinimng failed: invoke-rc.d: unknown initscript, /etc/init.d/plesk-php73-fpm not found.
invoke-rc.d: could not determine current runlevel
invoke-rc.d: emulating initscript action "status", returning "unknown"
Don't know how to detect if 'plesk-php73-fpm' service is registered on Ubuntu 18.04
[2020-06-08 20:03:41.096] ERR [util_exec] proc_close() failed ['/opt/psa/admin/bin/phpinimng' '--type' 'fpm' '--virtual-host' 'mydomain.local' '--service' 'plesk-php73-fpm' '--poold' '/opt/plesk/php/7.3/etc/php-fpm.d' '--remove'] with exit code [1] 
PHP Fatal error:  Uncaught PleskUtilException: phpinimng failed: invoke-rc.d: unknown initscript, /etc/init.d/plesk-php73-fpm not found.
invoke-rc.d: could not determine current runlevel
invoke-rc.d: emulating initscript action "status", returning "unknown"
Don't know how to detect if 'plesk-php73-fpm' service is registered on Ubuntu 18.04 in /opt/psa/admin/plib/Service/Agent.php:196
Stack trace:
#0 /opt/psa/admin/plib/PHosting/Apache.php(611): Service_Agent->execAndGetResponse('phpinimng', Array)
#1 /opt/psa/admin/plib/PHosting/Apache.php(579): PHosting_Apache->deletePhpFpmConfiguration('mydomain....', Array)
#2 [internal function]: PHosting_Apache->restartPhpFpmBatch()
#3 {main}
  thrown in /opt/psa/admin/plib/Service/Agent.php on line 196
exit status 255

It's quite tricky because "RUN" does the job during the build phase and Plesk (especially DB server) is not functioning during that time. If you do it in the run-time, everything will be ok.

Here is an example of Dockerfile:

FROM plesk/plesk

ADD post-install.sh /root/post-install.sh
RUN sed -i 's/^exec/sh \/root\/post-install.sh ; exec/' /run.sh

and corresponding post-install.sh:

#!/bin/bash

plesk bin subscription --create mydomain.local \
    -service-plan "Default Domain" \
    -ip 172.17.0.2 \
    -login myuser \
    -passwd "changeme1Q**"

exit 0

@sibprogrammer thanks, I'll try your suggestion!