Lumen does not read env from system during request

Lumen 5.4, MySql & Docker. I have following variables in global env

$ printenv

.env in my project the are present also, but they have different values.

  • How to use a bash script in Alpine Linux?
  • cannot run docker image with mounted folder
  • Can I config the hosts file for spring boot docker container?
  • Windows: Using Tensorflow with Python 3 instead of Python 2 (Docker)
  • Increasing mysql max_connections to 1024 in a docker container
  • HTTP 504 Gateway Time-out when serving static file with Django (Nginx + Gunicorn)
  • If I type in tinker env('DB_HOST'), it prints value from the global environment, but when application runs, it takes from the specified .env file. I think the problem exists within following function in Laravel\Lumen\Application :

     * Load a configuration file into the application.
     * @param  string  $name
     * @return void
    public function configure($name)
        if (isset($this->loadedConfigurations[$name])) {
        $this->loadedConfigurations[$name] = true;
        $path = $this->getConfigurationPath($name);
        if ($path) {
            $this->make('config')->set($name, require $path);

    How to override those values or make it to avoid those conditions: isset($this->loadedConfigurations[$name]) ?

  • wildfly docker image authentication issue
  • OpenShift V3 Generic WebHook Tag
  • Running nginx as non-root in Docker container gives permission denied error
  • ssh pseudo-tty causes PTY allocation request failed on channel 0
  • Tool to automate Docker Swarm
  • Deploy NoneJS application with Docker
  • One Solution collect form web for “Lumen does not read env from system during request”

    I still think that, regarding my comment, the answer remains the same. If you wish to utilize the docker environment variables as opposed to your local .env variables, then the config directory is still the way to go. In this case, it looks like you wish to target the database host. So let’s do that:

    In your config/database.php file, change the following:

    'mysql' => [
        'host' => getenv('DB_HOST') ?: env('DB_HOST', 'defaultvalue')

    Then only make reference to the host through the config file.


    You will get the ENV from your docker container if it exists, otherwise you will get the DB_HOST declaration from your .env file.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.