I wanna be able to deploy and run Magento 2 using Docker images

I am following Magento 2.2+ pipeline deployment docs:



When runnning pre-build php image with Magento source code, I need to create app/etc/env.php

I have tried to set configuration for env.php via bin/magento setup:config:set in my entrpoint (from ENV vars) which creates env.php file, but it does not include a way how to set 'install' => ['date' => 'Fri, 31 Jun 2020 18:00:00 +0000'] configuration. So Magento still does not know, that system is installed, and redirects to /setup.

Magento installation runs seprately (before runtime containers are created), and runtime containers should be able to scale easily.

And I dont want to rely on Docker volumes to bind app/etc/ folder to runtime containers. Containers should be self sufficient.

Am I missing something?


  • Hello, i am facing a similar issue. Did you find a way to handle it ?
    – MatMouth
    Jan 8, 2021 at 12:05
  • Hi @MatMouth I did, and it is flawless. Let me know, if my own answer to this topis is enough. Jan 9, 2021 at 14:54

1 Answer 1


I am not generating env.php via bin/magento setup:config:setup, instead I run setup:install in different container before I startup my php-fpm containers.

This setup container at the end copies its (newely generated) app/etc/env.php into shared volume (ex. app/init).

Then, when php-fpm container starts, its entrypoint copies this pre-generated env.php from shared volume to its app/etc/env.php.

This way all the containers are immutabble and deterministic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.