skip to Main Content

I have setup magento2 in docker container build using the docker file. Now I want to automate the database setup process so looking for the config file where I can set the database configuration like database name,username and password.

Reading few blog post says it is available at /app/etc/env.php but I cannot find the env.php file inside these location under my magento2 setup directory.

Those who are docker container for magento2, how do you automate the magento setup process (setting up database & Creating admin account) after magento2 installation.

Why is the env.php missing or does it comes only after initial database set up is done once.

2

Answers


  1. The env.php file generate by magento on installation.

    You can configure database and admin account during Installation process.

    Add Database configuration in installation steps

    Steps to add database  configuration

    Add admin account configuration in installation steps

    Configuring admin part  during installation step

    Login or Signup to reply.
  2. You can add the following commands in a RUN statement in your Dockerfile:

    sudo /usr/bin/mysql -e "create database magento"
    sudo /usr/bin/mysql -e "create user 'magento'@'localhost' "
    sudo /usr/bin/mysql -e "grant all privileges on magento.* to 'magento'@'localhost'"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search